pal = GetPalette(frame);
src = GetData(frame);
dst = image->GetData();
- transparent = GetTransparentColour(frame);
+ transparent = GetTransparentColourIndex(frame);
/* set transparent colour mask */
if (transparent != -1)
return GetFrame(frame)->delay;
}
+wxColour wxGIFDecoder::GetTransparentColour(size_t frame) const
+{
+ unsigned char *pal = GetFrame(frame)->pal;
+ int n = GetFrame(frame)->transparent;
+ if (n == -1)
+ return wxNullColour;
+
+ return wxColour(pal[n*3 + 0],
+ pal[n*3 + 1],
+ pal[n*3 + 2]);
+}
+
unsigned char* wxGIFDecoder::GetData(size_t frame) const { return (GetFrame(frame)->p); }
unsigned char* wxGIFDecoder::GetPalette(size_t frame) const { return (GetFrame(frame)->pal); }
unsigned int wxGIFDecoder::GetNcolours(size_t frame) const { return (GetFrame(frame)->ncolours); }
-int wxGIFDecoder::GetTransparentColour(size_t frame) const { return (GetFrame(frame)->transparent); }
+int wxGIFDecoder::GetTransparentColourIndex(size_t frame) const { return (GetFrame(frame)->transparent); }
{
while ((i = (unsigned char)stream.GetC()) != 0)
{
- stream.SeekI(i, wxFromCurrent);
- if (stream.Eof())
+ if (stream.Eof() || (stream.LastRead() == 0))
{
done = true;
break;
}
+ stream.SeekI(i, wxFromCurrent);
}
}
}
/* skip all data */
while ((i = (unsigned char)stream.GetC()) != 0)
{
+ if (stream.Eof() || (stream.LastRead() == 0))
+ {
+ Destroy();
+ return wxGIF_INVFORMAT;
+ }
stream.SeekI(i, wxFromCurrent);
}
}
if ((buf[8] & 0x80) == 0x80)
{
unsigned int local_ncolors = 2 << (buf[8] & 0x07);
- wxFileOffset pos = stream.TellI();
wxFileOffset numBytes = 3 * local_ncolors;
stream.SeekI(numBytes, wxFromCurrent);
- if (stream.TellI() != (pos + numBytes))
- {
- Destroy();
- return wxGIF_INVFORMAT;
- }
}
/* initial code size */
(void) stream.GetC();
+ if (stream.Eof() || (stream.LastRead() == 0))
+ {
+ Destroy();
+ return wxGIF_INVFORMAT;
+ }
/* skip all data */
while ((i = (unsigned char)stream.GetC()) != 0)
{
+ if (stream.Eof() || (stream.LastRead() == 0))
+ {
+ Destroy();
+ return wxGIF_INVFORMAT;
+ }
stream.SeekI(i, wxFromCurrent);
}
}