VIEW_TIF.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /* view_tif.c */
00025 
00026 void tif_display_line(unsigned char *pbgr, long line){
00027  unsigned char *p;
00028  register long i,l;
00029  l = (long)(y_size - 1 - line)*(long)(x4_size);
00030  p = (unsigned char *)(pixels+l);
00031  for(i=0;i<x_size;i++){
00032   *p++ = *(pbgr+2);
00033   *p++ = *(pbgr+1);
00034   *p++ = *(pbgr);
00035   pbgr+=4;
00036  }
00037 }
00038 
00039 extern long ReadTIF(char *filename, short info_only);
00040 
00041 static int tifview(HWND hWnd){
00042  int i;
00043  long imagesize;
00044  LPBITMAPINFOHEADER lpbi;
00045  if(ReadTIF(CurrentFile,1) == 0){
00046    LoadErrMsg(IDX_ERR_NOTIF);
00047    return 0;
00048  }
00049  x4_size=ALIGNULONG(x_size*3);
00050  FreeDib();
00051  lpBitmapHeader = (LPSTR)X__Malloc((long)sizeof(BITMAPINFOHEADER));
00052  if(lpBitmapHeader == NULL){
00053    LoadErrMsg(IDX_ERR_MEMORY);
00054    return 0;
00055  }
00056  lpbi=(LPBITMAPINFOHEADER)lpBitmapHeader;
00057  lpbi->biSize=sizeof(BITMAPINFOHEADER);
00058  lpbi->biWidth=(DWORD)x_size;
00059  lpbi->biHeight=(DWORD)y_size;
00060  lpbi->biPlanes=1;
00061  lpbi->biBitCount=24;
00062  lpbi->biCompression=BI_RGB;
00063  imagesize = lpbi->biSizeImage = (DWORD)x4_size*(DWORD)y_size;
00064  lpbi->biXPelsPerMeter=0;
00065  lpbi->biYPelsPerMeter=0;
00066  lpbi->biClrUsed=0;
00067  lpbi->biClrImportant=0;
00068  hpalCurrent=CreateImagePalette(lpbi);  /* will set up a dummy palette */
00069  lpBitmapBits=(LPSTR)X__Malloc(imagesize);
00070  if(lpBitmapBits == NULL){
00071    LoadErrMsg(IDX_ERR_MEMORY);
00072    FreeDib();
00073    return 0;
00074  }
00075  memset(lpBitmapBits,0,imagesize);
00076  pixels=lpBitmapBits;
00077  if(ReadTIF(CurrentFile,0) == 0){
00078    LoadErrMsg(IDX_ERR_BADREAD);
00079    FreeDib();
00080    return 0;
00081  }
00082  hbmCurrent=BitmapFromDib(lpBitmapHeader,lpBitmapBits,hpalCurrent);
00083  if(hbmCurrent == NULL)LoadErrMsg(IDX_ERR_NOBITMAP);
00084  SizeWindow(hWnd);
00085  return 1;
00086 }

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6