-
- pos = 0;
- lastcode = readcode;
- }
- while (code != ab_fin);
-
- return 0;
-}
-
-
-
-/* readgif:
- * Reads a GIF image from the file with filename 'nombre' in the
- * IMAGEN structure pointed by 'img'. Can read GIFs with any bit
- * size (color depth), but the output image is always expanded
- * to 8 bits per pixel. Also, the image palette always contains
- * 256 colors, although some of them may be unused. Returns E_OK
- * (== 0) on success, or an error code if something fails. Error
- * codes are E_ARCHIVO, E_FORMATO, E_MEMORIA (see above).
- */
-int gifDecoder::readgif(IMAGEN *img)
-{
- int size, ncolors, bits, interl, i;
- unsigned char pal[768];
- unsigned char buf[16];
-
-
- /* read header and logical screen descriptor block (LSDB) */
- f->Read(buf, 13);
-
- /* check GIF signature */
- if (memcmp(buf, "GIF", 3) != 0) return E_FORMATO;
-
- /* load global color map if available */
- if ((buf[10] & 0x80) == 0x80)
- {
- ncolors = 2 << (buf[10] & 0x07);
- f->Read(pal, 3 * ncolors);
- }
-
- /* assume no transparent color */
- img->transparent = -1;
-
- /* skip most extensions */
- while (((unsigned char)f->GetC()) == 0x21) /* separator */
- {
- if (((unsigned char)f->GetC()) == 0xF9) /* graphic control ext. */
- {
- f->Read(buf, 6);
- if (buf[1] & 0x01)
- img->transparent = buf[4];
- }
- else
- while ((i = (unsigned char)f->GetC()) != 0) /* byte count */
- f->SeekI(i, wxFromCurrent);
- }
-
- /* read image descriptor block (IDB) */
- f->Read(buf, 9);
- img->w = buf[4] + 256 * buf[5];
- img->h = buf[6] + 256 * buf[7];
- size = img->w * img->h;
- interl = ((buf[8] & 0x40)? 1 : 0);
-
- /* load local color map if available */
- if ((buf[8] & 0x80) == 0x80)
- {
- ncolors = 2 << (buf[8] & 0x07);
- f->Read(pal, 3 * ncolors);
- }
-
- /* get initial code size from first byte in raster data */
- bits = (unsigned char)f->GetC();
-
- /* allocate memory for image and palette */
- if ((img->p = (unsigned char*) malloc(size)) == NULL) return E_MEMORIA;
- if ((img->pal = (unsigned char*) malloc(768)) == NULL) return E_MEMORIA;
-
- /* shift palette to fit VGA 6-bit format */
- for (i = 0; i < 768; i++)
- (img->pal)[i] = (unsigned char)pal[i]; /* >> 2 not in wxWin */
-
- /* decode GIF */
- dgif(img, interl, bits);
-
- /* finish successfully :-) */
- return E_OK;
-}
-
-
-
-/*
-
-FOLLOWING CODE IS BY V.S. :
-
-*/
-
-//-----------------------------------------------------------------------------
-// wxGIFHandler
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
-
-bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream )
-{
- unsigned char *ptr, *src, *pal;
- IMAGEN igif;
- int i;
- gifDecoder *decod;
-
- image->Destroy();
-
- decod = new gifDecoder(&stream);
-
- if (decod->readgif(&igif) != E_OK) {
- wxLogDebug("Error reading GIF");