diff options
| author | Manolo Gouy <Manolo> | 2011-02-01 10:13:54 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-02-01 10:13:54 +0000 |
| commit | 45e539fff80a5b0040d517f01d82b7aa6cdb7d31 (patch) | |
| tree | 4d02950654586736bf5d0c38c9272aa2d4261a89 /src | |
| parent | 2192b8aed24833a5282c53be6f1df2b5861d0b31 (diff) | |
fl_draw_image() on Mac OS and to a printer requires the image data to be kept until the
page is finished. Thus, we now duplicate this data when the output is a printer, so the
caller of the function does not have to take into account this Mac OS specificity.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8349 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Paged_Device.cxx | 26 | ||||
| -rw-r--r-- | src/Fl_Quartz_Printer.mm | 2 | ||||
| -rw-r--r-- | src/fl_draw_image_mac.cxx | 15 |
3 files changed, 10 insertions, 33 deletions
diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx index 239f8b83a..eb604259e 100644 --- a/src/Fl_Paged_Device.cxx +++ b/src/Fl_Paged_Device.cxx @@ -141,35 +141,9 @@ void Fl_Paged_Device::print_window_part(Fl_Window *win, int x, int y, int w, int save_front->show(); current->set_current(); fl_draw_image(image_data, delta_x, delta_y, w, h, 3); -#ifdef __APPLE__ - add_image(image_data); -#else delete image_data; -#endif } - -#ifdef __APPLE__ -void Fl_Paged_Device::add_image(const uchar *data) -{ - struct chain_elt *elt = (struct chain_elt *)calloc(sizeof(struct chain_elt), 1); - elt->data = data; - if (image_list_) { elt->next = image_list_; } - image_list_ = elt; -} - -void Fl_Paged_Device::delete_image_list() -{ - while(image_list_) { - struct chain_elt *next = image_list_->next; - if (image_list_->data) delete (uchar*) image_list_->data; // msvc6 compilation fix - free(image_list_); - image_list_ = next; - } -} -#endif - - /** @brief Starts a print job. * diff --git a/src/Fl_Quartz_Printer.mm b/src/Fl_Quartz_Printer.mm index 200b41dd6..6f4c07a1b 100644 --- a/src/Fl_Quartz_Printer.mm +++ b/src/Fl_Quartz_Printer.mm @@ -261,7 +261,6 @@ int Fl_System_Printer::start_page (void) angle = 0; scale_x = scale_y = 1; win_scale_x = win_scale_y = 1; - image_list_ = NULL; if(orientation == kPMPortrait) CGContextTranslateCTM(fl_gc, margins.left, margins.bottom + h); else @@ -284,7 +283,6 @@ int Fl_System_Printer::end_page (void) CGContextRestoreGState(fl_gc); CGContextRestoreGState(fl_gc); OSStatus status = PMSessionEndPageNoDialog(printSession); - delete_image_list(); gc = NULL; return status != noErr; } diff --git a/src/fl_draw_image_mac.cxx b/src/fl_draw_image_mac.cxx index 84b904436..72c34f888 100644 --- a/src/fl_draw_image_mac.cxx +++ b/src/fl_draw_image_mac.cxx @@ -30,6 +30,7 @@ #include <config.h> #include <FL/Fl.H> #include <FL/fl_draw.H> +#include <FL/Fl_Printer.H> #include <FL/x.H> #define MAXBUFFER 0x40000 // 256k @@ -39,7 +40,7 @@ static void dataReleaseCB(void *info, const void *data, size_t size) delete[] (uchar *)data; } -/** +/* * draw an image based on the input parameters * * buf: image source data @@ -63,10 +64,14 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, const void *array = buf; uchar *tmpBuf = 0; - if (cb) { + if (cb || Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { tmpBuf = new uchar[ H*W*delta ]; - for (int i=0; i<H; i++) { - cb(userdata, 0, i, W, tmpBuf+i*W*delta); + if (cb) { + for (int i=0; i<H; i++) { + cb(userdata, 0, i, W, tmpBuf+i*W*delta); + } + } else { + memcpy(tmpBuf, buf, H*W*delta); } array = (void*)tmpBuf; linedelta = W*delta; @@ -86,7 +91,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, size_t size ); #endif - CGDataProviderReleaseDataCallback releaseCB = ( cb ? dataReleaseCB : NULL); + CGDataProviderReleaseDataCallback releaseCB = ( tmpBuf ? dataReleaseCB : NULL); CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, linedelta*H, releaseCB); CGImageRef img = CGImageCreate( W, H, 8, 8*delta, linedelta, //lut, delta&1?kCGImageAlphaNone:kCGImageAlphaNoneSkipLast, |
