summaryrefslogtreecommitdiff
path: root/src/Fl_Image.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2012-03-14 08:49:36 +0000
committerManolo Gouy <Manolo>2012-03-14 08:49:36 +0000
commit7d0b5d05cb14b2a14b891e4957d3db30d451b0f1 (patch)
tree2f6bb78f4937483d3fc4aaedffa7c5ebe672c672 /src/Fl_Image.cxx
parentf6cb583e27ffd6046da7a28edc35fc8001ea9415 (diff)
Simplified Fl_Paged_Device::print_window() under Mac OS
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9282 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Image.cxx')
-rw-r--r--src/Fl_Image.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index 891fff48b..4a3764a18 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -446,6 +446,11 @@ static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h
}
#ifdef __APPLE__
+static void imgProviderReleaseData (void *info, const void *data, size_t size)
+{
+ delete[] (unsigned char *)data;
+}
+
void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
// Don't draw an empty image...
@@ -456,14 +461,26 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP,
if (start(img, XP, YP, WP, HP, img->w(), img->h(), cx, cy, X, Y, W, H)) {
return;
}
+ CGDataProviderReleaseDataCallback release_cb = NULL;
+ const uchar* img_bytes = img->array;
+ int ld = img->ld();
if (!img->id_) {
CGColorSpaceRef lut = 0;
+ if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) {
+ // when printing, duplicate the image data so it can be deleted later, at page end
+ release_cb = imgProviderReleaseData;
+ Fl_RGB_Image* img2 = (Fl_RGB_Image*)img->copy();
+ img2->alloc_array = 0;
+ img_bytes = img2->array;
+ ld = 0;
+ delete img2;
+ }
if (img->d()<=2)
lut = CGColorSpaceCreateDeviceGray();
else
lut = CGColorSpaceCreateDeviceRGB();
- CGDataProviderRef src = CGDataProviderCreateWithData( 0L, img->array, img->w()*img->h()*img->d(), 0L);
- img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8, img->ld()?img->ld():img->w()*img->d(),
+ CGDataProviderRef src = CGDataProviderCreateWithData( NULL, img_bytes, img->w()*img->h()*img->d(), release_cb);
+ img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8, ld?ld:img->w()*img->d(),
lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
src, 0L, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut);