diff options
Diffstat (limited to 'src/Fl_Pixmap.cxx')
| -rw-r--r-- | src/Fl_Pixmap.cxx | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 42ab0bb0a..ecf45915b 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -47,6 +47,7 @@ #include <FL/Fl_Widget.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Pixmap.H> +#include <FL/Fl_Printer.H> #include <stdio.h> #include "flstring.h" @@ -74,6 +75,10 @@ void Fl_Pixmap::measure() { } void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { + if(fl_device->type() == Fl_Device::postscript_device) { + ((Fl_Virtual_Printer*)fl_device)->draw(this, XP, YP, WP, HP, cx, cy); + return; + } // ignore empty or bad pixmap data: if (!data()) { draw_empty(XP, YP); @@ -139,7 +144,54 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { fl_restore_clip(); } #elif defined(WIN32) - if (mask) { + if (fl_device->type() == Fl_Device::gdi_printer) { + typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT); + static HMODULE hMod = NULL; + static fl_transp_func fl_TransparentBlt = NULL; + if (!hMod) { + hMod = LoadLibrary("MSIMG32.DLL"); + if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt"); + } + if (hMod) { +# define UNLIKELY_RGB_COLOR 2,3,4 // a nearly black color unlikely to occur in pixmaps +# define WIN_COLOR RGB(2,3,4) + Fl_Offscreen tmp_id = fl_create_offscreen(w(), h()); + fl_begin_offscreen(tmp_id); + uchar *bitmap = 0; + fl_mask_bitmap = &bitmap; + // draw pixmap to offscreen using the unlikely color for background + fl_draw_pixmap(data(), 0, 0, fl_rgb_color(UNLIKELY_RGB_COLOR) ); + fl_end_offscreen(); + HDC new_gc = CreateCompatibleDC(fl_gc); + int save = SaveDC(new_gc); + SelectObject(new_gc, (void*)tmp_id); + // print all of offscreen but its parts using unlikely color + fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, w(), h(), WIN_COLOR ); + RestoreDC(new_gc,save); + // This is an approximate algorithm that fails to print pixmap pixels that would use the unlikely color. + // It can be transformed into an exact algorithm by adding the following commented out statements + // that print pixmap one more time hiding another color (any color would fit) + /* +# define UNLIKELY_RGB_COLOR2 4,3,2 +# define WIN_COLOR2 RGB(4,3,2) + { + fl_begin_offscreen(tmp_id); + fl_draw_pixmap(data(), 0, 0, fl_rgb_color(UNLIKELY_RGB_COLOR2) ); + fl_end_offscreen(); + } + save = SaveDC(new_gc); + SelectObject(new_gc, (void*)tmp_id); + fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, w(), h(), WIN_COLOR2 ); + RestoreDC(new_gc,save); + */ + DeleteDC(new_gc); + fl_delete_offscreen(tmp_id); + } + else { + fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); + } + } + else if (mask) { HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, (void*)mask); |
