...
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,13 +40,14 @@ FOLLOWING CODE IS BY G.R.G. :
|
|||||||
Guillermo Rodriguez Garcia
|
Guillermo Rodriguez Garcia
|
||||||
<guille@iies.es>
|
<guille@iies.es>
|
||||||
|
|
||||||
Version: 2.0
|
Version: 2.1
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int w; /* width */
|
int w; /* width */
|
||||||
int h; /* height */
|
int h; /* height */
|
||||||
|
int transparent; /* transparent color (-1 = none) */
|
||||||
unsigned char *p; /* bitmap */
|
unsigned char *p; /* bitmap */
|
||||||
unsigned char *pal; /* palette */
|
unsigned char *pal; /* palette */
|
||||||
} IMAGEN;
|
} IMAGEN;
|
||||||
@@ -60,7 +61,7 @@ typedef struct
|
|||||||
Guillermo Rodriguez Garcia
|
Guillermo Rodriguez Garcia
|
||||||
<guille@iies.es>
|
<guille@iies.es>
|
||||||
|
|
||||||
Version: 2.0
|
Version: 2.1
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@@ -94,12 +95,19 @@ class gifDecoder
|
|||||||
int readgif(IMAGEN *img);
|
int readgif(IMAGEN *img);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mygetc() {return (unsigned char)f -> GetC();}
|
unsigned char mygetc();
|
||||||
// This is NEEDED! GetC is char (signed) why we need unsigned value
|
// This is NEEDED! GetC is char (signed) why we need unsigned value
|
||||||
// from here
|
// from here
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char gifDecoder::mygetc()
|
||||||
|
{
|
||||||
|
unsigned char c;
|
||||||
|
f -> Read(&c, 1);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* getcode:
|
/* getcode:
|
||||||
* Reads the next code from the file, with size 'bits'
|
* Reads the next code from the file, with size 'bits'
|
||||||
@@ -303,13 +311,26 @@ int gifDecoder::readgif(IMAGEN *img)
|
|||||||
f -> Read(pal, 3 * ncolors);
|
f -> Read(pal, 3 * ncolors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip extensions */
|
/* assume no transparent color */
|
||||||
while (mygetc() == 0x21) /* separator */
|
img->transparent = -1;
|
||||||
{
|
|
||||||
mygetc(); /* function code */
|
|
||||||
|
|
||||||
while ((i = mygetc()) != 0) /* byte count */
|
/* skip most extensions */
|
||||||
f -> SeekI(i, wxFromCurrent);
|
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) */
|
/* read image descriptor block (IDB) */
|
||||||
@@ -392,6 +413,13 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
*(ptr++) = pal[3 * (*src) + 2];
|
*(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.pal);
|
||||||
free(igif.p);
|
free(igif.p);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -404,3 +432,8 @@ bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user