VIEW_GIF.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 int out_line(unsigned char *linepixels, int linelen){
00027 register long l;
00028 l = (long)(y_size - 1 - rowcount)*(long)(x4_size);
00029 memcpy(pixels + l, linepixels, linelen);
00030 rowcount+=abs(rowinc);
00031 if(rowcount >= y_size){
00032 if (rowinc == -8){rowinc=8; rowcount=4;}
00033 else if(rowinc == 8){rowinc=4; rowcount=2;}
00034 else if(rowinc == 4){rowinc=2; rowcount=1;}
00035 }
00036 return 0;
00037 }
00038
00039 static int gifview(HWND hWnd){
00040 int i,err;
00041 char temp[128];
00042 long imagesize;
00043 LPBITMAPINFOHEADER lpbi;
00044 FreeDib();
00045 rowcount=0;
00046 rowinc=1;
00047 strcpy(temp,CurrentFile);
00048 if((err=read_gif_image(temp,1)) < 0){
00049 if(err == -1)LoadErrMsg(IDX_ERR_NOGIF);
00050 else LoadErrMsg(IDX_ERR_BADGIF);
00051 return 0;
00052 }
00053 if(gif_iLace)rowinc = -8;
00054 x4_size = ALIGNULONG(x_size);
00055 lpBitmapHeader = (LPSTR)X__Malloc((long)sizeof(BITMAPINFOHEADER)
00056 +256L*sizeof(RGBQUAD));
00057 if(lpBitmapHeader == NULL){
00058 LoadErrMsg(IDX_ERR_MEMORY);
00059 return 0;
00060 }
00061 lpbi=(LPBITMAPINFOHEADER)lpBitmapHeader;
00062 lpbi->biSize=sizeof(BITMAPINFOHEADER);
00063 lpbi->biWidth=(DWORD)x4_size;
00064 lpbi->biHeight=(DWORD)y_size;
00065 lpbi->biPlanes=1;
00066 lpbi->biBitCount=8;
00067 lpbi->biCompression=BI_RGB;
00068 imagesize = lpbi->biSizeImage = (DWORD)x4_size*(DWORD)y_size;
00069 lpbi->biXPelsPerMeter=0;
00070 lpbi->biYPelsPerMeter=0;
00071 lpbi->biClrUsed=256;
00072 lpbi->biClrImportant=256;
00073 pRgb=(RGBQUAD *)((LPSTR)lpbi + lpbi->biSize);
00074 for(i=0;i<256;i++){
00075 pRgb[i].rgbRed = p_red[i] << 2;
00076 pRgb[i].rgbGreen = p_green[i] << 2;
00077 pRgb[i].rgbBlue = p_blue[i] << 2;
00078 }
00079 hpalCurrent=CreateImagePalette(lpbi);
00080 lpBitmapBits=(LPSTR)X__Malloc(imagesize);
00081 if(lpBitmapBits == NULL){
00082 LoadErrMsg(IDX_ERR_MEMORY);
00083 FreeDib();
00084 return 0;
00085 }
00086 memset(lpBitmapBits,0,imagesize);
00087 pixels=lpBitmapBits;
00088 if(read_gif_image(temp,0) < 0){
00089 LoadErrMsg(IDX_ERR_BADREAD);
00090 FreeDib();
00091 return 0;
00092 }
00093 hbmCurrent=BitmapFromDib(lpBitmapHeader,lpBitmapBits,hpalCurrent);
00094 if(hbmCurrent == NULL)LoadErrMsg(IDX_ERR_NOBITMAP);
00095 SizeWindow(hWnd);
00096 return 1;
00097 }