mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 05:35:29 +08:00
Fixed reading of .pbm image files: the black & white pixels were reversed,
and P4-formatted files of width a multiple of 8 were handled incorrectly. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10558 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -17,6 +17,8 @@ CHANGES IN FLTK 1.3.4 RELEASED: ??? ?? ????
|
|||||||
or not (STR #3142). It also captures subwindows of GL windows.
|
or not (STR #3142). It also captures subwindows of GL windows.
|
||||||
- Fl::delete_widget() now hides the widget or window immediately
|
- Fl::delete_widget() now hides the widget or window immediately
|
||||||
(i.e. when called) - only destruction is delayed as before.
|
(i.e. when called) - only destruction is delayed as before.
|
||||||
|
- Reading of .pbm image files is fixed: 1 is now interpreted as
|
||||||
|
black, and images of width a multiple of 8 are correctly read.
|
||||||
|
|
||||||
CHANGES IN FLTK 1.3.3 RELEASED: Nov 03 2014
|
CHANGES IN FLTK 1.3.3 RELEASED: Nov 03 2014
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -133,6 +133,10 @@ Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read
|
|||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 1 :
|
case 1 :
|
||||||
|
for (x = w(); x > 0; x --)
|
||||||
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = (uchar)(255 * (1-val));
|
||||||
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
for (x = w(); x > 0; x --)
|
for (x = w(); x > 0; x --)
|
||||||
if (fscanf(fp, "%d", &val) == 1) *ptr++ = (uchar)(255 * val / maxval);
|
if (fscanf(fp, "%d", &val) == 1) *ptr++ = (uchar)(255 * val / maxval);
|
||||||
@@ -147,17 +151,17 @@ Fl_PNM_Image::Fl_PNM_Image(const char *name) // I - File to read
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 4 :
|
case 4 :
|
||||||
for (x = w(), byte = (uchar)getc(fp), bit = 128; x > 0; x --) {
|
for (x = w(), byte = (uchar)getc(fp), bit = 128; x > 0; x --) {
|
||||||
if (byte & bit) *ptr++ = 255;
|
if ((byte & bit) == 0) *ptr++ = 255; // 0 bit for white pixel
|
||||||
else *ptr++ = 0;
|
else *ptr++ = 0; // 1 bit for black pixel
|
||||||
|
|
||||||
if (bit > 1) bit >>= 1;
|
if (bit > 1) bit >>= 1;
|
||||||
else {
|
else {
|
||||||
bit = 128;
|
bit = 128;
|
||||||
byte = (uchar)getc(fp);
|
if (x > 1) byte = (uchar)getc(fp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 5 :
|
case 5 :
|
||||||
case 6 :
|
case 6 :
|
||||||
|
|||||||
Reference in New Issue
Block a user