diff options
| -rw-r--r-- | FL/Fl_System_Driver.H | 2 | ||||
| -rw-r--r-- | src/Fl_PNG_Image.cxx | 13 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 8 |
4 files changed, 14 insertions, 10 deletions
diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H index 2f52f10ba..5073be7ec 100644 --- a/FL/Fl_System_Driver.H +++ b/FL/Fl_System_Driver.H @@ -145,6 +145,8 @@ public: virtual int preferences_need_protection_check() {return 0;} // implement to support Fl_Plugin_Manager::load() virtual void *dlopen(const char *filename) {return NULL;} + // the default implementation is most probably enough + virtual void png_extra_rgba_processing(unsigned char *array, int w, int h) {} }; #endif // FL_SYSTEM_DRIVER_H diff --git a/src/Fl_PNG_Image.cxx b/src/Fl_PNG_Image.cxx index 1d94e9803..aa9635ee9 100644 --- a/src/Fl_PNG_Image.cxx +++ b/src/Fl_PNG_Image.cxx @@ -26,10 +26,11 @@ // Include necessary header files... // +#include <config.h> #include <FL/Fl.H> +#include <FL/Fl_System_Driver.H> #include <FL/Fl_PNG_Image.H> #include <FL/Fl_Shared_Image.H> -#include <config.h> #include <stdio.h> #include <stdlib.h> #include <FL/fl_utf8.h> @@ -206,15 +207,7 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p for (i = png_set_interlace_handling(pp); i > 0; i --) png_read_rows(pp, rows, NULL, h()); -#ifdef WIN32 - // Some Windows graphics drivers don't honor transparency when RGB == white - if (channels == 4) { - // Convert RGB to 0 when alpha == 0... - uchar *ptr = (uchar *)array; - for (i = w() * h(); i > 0; i --, ptr += 4) - if (!ptr[3]) ptr[0] = ptr[1] = ptr[2] = 0; - } -#endif // WIN32 + if (channels == 4) Fl::system_driver()->png_extra_rgba_processing((uchar*)array, w(), h()); // Free memory and return... delete[] rows; diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index e5bfb41b8..5e580f15c 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -83,6 +83,7 @@ public: virtual char *preference_rootnode(Fl_Preferences *prefs, Fl_Preferences::Root root, const char *vendor, const char *application); virtual void *dlopen(const char *filename); + virtual void png_extra_rgba_processing(unsigned char *array, int w, int h); }; #endif // FL_WINAPI_SYSTEM_DRIVER_H diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index 9df5b2f71..529f9ade7 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -868,6 +868,14 @@ void *Fl_WinAPI_System_Driver::dlopen(const char *filename) return LoadLibrary(filename); } +void Fl_WinAPI_System_Driver::png_extra_rgba_processing(unsigned char *ptr, int w, int h) +{ + // Some Windows graphics drivers don't honor transparency when RGB == white + // Convert RGB to 0 when alpha == 0... + for (int i = w * h; i > 0; i --, ptr += 4) { + if (!ptr[3]) ptr[0] = ptr[1] = ptr[2] = 0; + } +} // // End of "$Id$". |
