The following patch adds support of 16bit pnm images as they
are generated e.g. by ImageMagick's convert.
I am not sure about the endian check however.
Johannes
--- Fl_PNM_Image.cxx.orig 2007-04-24 16:45:19.000000000 +0200
+++ Fl_PNM_Image.cxx 2007-04-24 16:47:51.000000000 +0200
@@ -39,6 +39,11 @@
#include <stdlib.h>
#include "flstring.h"
+#ifdef WORDS_BIGENDIAN
+#define HBO(x) (x)
+#else
+#define HBO(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
+#endif
//
// 'Fl_PNM_Image::Fl_PNM_Image()' - Load a PNM image...
@@ -158,7 +162,17 @@
case 5 :
case 6 :
- fread(ptr, w(), d(), fp);
+ if (maxval < 256) {
+ fread(ptr, w(), d(), fp);
+ } else {
+ for (x = w(); x > 0; x --) {
+ unsigned short val[3];
+ fread(val, sizeof(val), 1, fp);
+ *ptr++ = (uchar)(255 * HBO(val[0]) / maxval);
+ *ptr++ = (uchar)(255 * HBO(val[1]) / maxval);
+ *ptr++ = (uchar)(255 * HBO(val[2]) / maxval);
+ }
+ }
break;
case 7 : /* XV 3:3:2 thumbnail format */
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev