Guillermo Rodriguez Garcia
<guille@iies.es>
- Version: 2.0
+ Version: 2.1
*************************************************************************/
typedef struct
{
int w; /* width */
int h; /* height */
+ int transparent; /* transparent color (-1 = none) */
unsigned char *p; /* bitmap */
unsigned char *pal; /* palette */
} IMAGEN;
Guillermo Rodriguez Garcia
<guille@iies.es>
- Version: 2.0
+ Version: 2.1
*************************************************************************/
int readgif(IMAGEN *img);
private:
- int mygetc() {return (unsigned char)f -> GetC();}
+ unsigned char mygetc();
// This is NEEDED! GetC is char (signed) why we need unsigned value
// from here
};
+unsigned char gifDecoder::mygetc()
+{
+ unsigned char c;
+ f -> Read(&c, 1);
+ return c;
+}
+
/* getcode:
* Reads the next code from the file, with size 'bits'
f -> Read(pal, 3 * ncolors);
}
- /* skip extensions */
- while (mygetc() == 0x21) /* separator */
- {
- mygetc(); /* function code */
+ /* assume no transparent color */
+ img->transparent = -1;
- while ((i = mygetc()) != 0) /* byte count */
- f -> SeekI(i, wxFromCurrent);
+ /* skip most extensions */
+ while (mygetc() == 0x21) /* separator */
+ {
+ wxLogDebug("ugh");
+ if (mygetc() == 0xF9) /* graphic control ext. */
+ {
+ wxLogDebug("...");
+ f->Read(buf, 6);
+ wxLogDebug("buf[1] is %i (%i)", buf[1], buf[1] & 0x01);
+ if (buf[1] & 0x01) {
+ wxLogDebug("setting transparen %i", buf[4]);
+ img->transparent = buf[4];
+ }
+ }
+ else
+ while ((i = mygetc()) != 0) /* byte count */
+ f->SeekI(i, wxFromCurrent);
}
/* read image descriptor block (IDB) */
*(ptr++) = pal[3 * (*src) + 2];
}
+ if (igif.transparent != -1) {
+ wxLogDebug("oko");
+ image->SetMaskColour(pal[3 * (igif.transparent) + 0], pal[3 * (igif.transparent) + 0], pal[3 * (igif.transparent) + 0]);
+ image->SetMask(TRUE);
+ }
+
+ wxLogDebug("(unsigned int)%i", (unsigned int)-1);
free(igif.pal);
free(igif.p);
return TRUE;
}
+
+
+
+
+