VIEW_GIF.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_gif.c */
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 }

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