VIEW_TIF.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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);
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 }