diff options
| author | Manolo Gouy <Manolo> | 2017-09-13 06:29:16 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-09-13 06:29:16 +0000 |
| commit | 8767da2dfd454189a334c3c0ca5182de3bc831a4 (patch) | |
| tree | 7c576206a5f85ed7eaa49b594dbcfffeb9632d04 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx | |
| parent | a1ab2eb7b2b4341a3e952f60daded1ec2e68d05b (diff) | |
Mac OS: explain more accurately in comments how the tricky part of printing an Fl_RGB_Image is handled.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12454 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx index 00d96ea42..a49d2d15c 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx @@ -165,19 +165,22 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, if (!ld) ld = img->w() * img->d(); CGDataProviderRef src; if ( has_feature(PRINTER) ) { - // When printing, the image data is used when the printed page is completed. - // At that stage, the image has possibly been deleted. It is therefore necessary - // to print a copy of the image data. The mask_ member of the Fl_RGB_Image is used to avoid - // repeating the copy operation if the image is printed again. - // The CGImage data provider deletes the copy when the Fl_RGB_Image is deleted. - uchar *copy = new uchar[ld * img->h()]; - memcpy(copy, img->array, ld * img->h()); - src = CGDataProviderCreateWithData(NULL, copy, ld * img->h(), dataReleaseCB); + // When printing, the data at img->array are used when the printed page is completed, + // that is, after return from this function. + // At that stage, the img object has possibly been deleted. It is therefore necessary + // to use a copy of img->array for printing. The mask_ member of img + // is used to avoid repeating the copy operation if img is printed again. + // The CGImage data provider deletes the copy at the latest of these two events: + // deletion of img, and completion of the page where img was printed. + size_t total = ld * img->h(); + uchar *copy = new uchar[total]; + memcpy(copy, img->array, total); + src = CGDataProviderCreateWithData(NULL, copy, total, dataReleaseCB); *Fl_Graphics_Driver::mask(img) = 1; } else { - // the CGImage data provider need not release the image data. + // the CGImage data provider must not release the image data. src = CGDataProviderCreateWithData(NULL, img->array, ld * img->h(), NULL); - } + } cgimg = CGImageCreate(img->w(), img->h(), 8, img->d()*8, ld, lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast, src, 0L, false, kCGRenderingIntentDefault); |
