From 8306c3d0b31d4e60a9ba9c4d0ca4ed6a32226de1 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 9 Jul 2010 17:31:33 +0000 Subject: Fixed fl_XXX_offscreen functions when the current output goes to a printer or a PostScript device git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7671 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Double_Window.cxx | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 03e0240b8..a09134879 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -65,8 +65,28 @@ void Fl_Double_Window::show() { Fl_Window::show(); } +static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + +void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + if( fl_graphics_driver == fl_display_device->driver()) { + fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy); + } + else { // when copy is not to the display + fl_begin_offscreen(pixmap); + uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0); + fl_end_offscreen(); + fl_draw_image(img, x, y, w, h, 3, 0); + delete img; + } +} + #if defined(USE_X11) +static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y); +} + + // maybe someone feels inclined to implement alpha blending on X11? char fl_can_do_alpha_blending() { return 0; @@ -134,7 +154,7 @@ HDC fl_makeDC(HBITMAP bitmap) { return new_gc; } -void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { +static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); @@ -195,7 +215,7 @@ static void bmProviderRelease (void *src, const void *data, size_t size) if(count == 1) free((void*)data); } -void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { +static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { CGContextRef src = (CGContextRef)osrc; void *data = CGBitmapContextGetData(src); int sw = CGBitmapContextGetWidth(src); @@ -230,8 +250,11 @@ const int stack_max = 16; static int stack_ix = 0; static CGContextRef stack_gc[stack_max]; static Window stack_window[stack_max]; +static Fl_Surface_Device *_ss; void fl_begin_offscreen(Fl_Offscreen ctx) { + _ss = fl_surface; + fl_display_device->set_current(); if (stack_ixset_current(); } extern void fl_restore_clip(); -- cgit v1.2.3