summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-08-08 02:34:06 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-08-08 02:34:06 +0000
commit4fa1a3edb4e7208b8af190c0c07f03f74f618c05 (patch)
tree9740b2d7e5b8c983e3327c7a724969eb1cbbf4c1
parentafbd833c04cbde1dbb04f390d394635fad8ae5e2 (diff)
Fl_GIF_Image did not handle images with an incorrect number of
data bits (STR #914) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4480 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--src/Fl_GIF_Image.cxx9
2 files changed, 9 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 32cb701e0..9e6074dc1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745, STR #942, STR #931)
+ - Fl_GIF_Image did not handle images with an incorrect
+ number of data bits (STR #914)
- Fixed some plastic drawing artifacts (STR #906)
- Fl_Help_View now draws the box outside the scrollbars,
like the other scrollable widgets (STR #871)
diff --git a/src/Fl_GIF_Image.cxx b/src/Fl_GIF_Image.cxx
index be8014cf7..5d6fc9af6 100644
--- a/src/Fl_GIF_Image.cxx
+++ b/src/Fl_GIF_Image.cxx
@@ -175,7 +175,6 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
if (ch&0x80) {
// read local color map
int n = 2<<(ch&7);
- if (n > ColorMapSize) ColorMapSize = n;
for (i=0; i < n; i++) {
Red[i] = NEXTBYTE;
Green[i] = NEXTBYTE;
@@ -183,7 +182,6 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
}
}
CodeSize = NEXTBYTE+1;
-
break; // okay, this is the image we want
} else {
Fl::warning("%s: unknown gif code 0x%02x", infname, i);
@@ -194,6 +192,13 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
while (blocklen>0) {while (blocklen--) {NEXTBYTE;} blocklen=NEXTBYTE;}
}
+ if (BitsPerPixel >= CodeSize)
+ {
+ // Workaround for broken GIF files...
+ BitsPerPixel = CodeSize - 1;
+ ColorMapSize = 1 << BitsPerPixel;
+ }
+
uchar *Image = new uchar[Width*Height];
int YC = 0, Pass = 0; /* Used to de-interlace the picture */