133
137
fl_delete_bitmask((Fl_Bitmask)mask);
138
143
Fl_Image *Fl_RGB_Image::copy(int W, int H) {
144
Fl_RGB_Image *new_image; // New RGB image
145
uchar *new_array; // New array for image data
139
147
// Optimize the simple copy where the width and height are the same,
140
148
// or when we are copying an empty image...
141
149
if ((W == w() && H == h()) ||
142
150
!w() || !h() || !d() || !array) {
143
return new Fl_RGB_Image(array, w(), h(), d(), ld());
152
// Make a copy of the image data and return a new Fl_RGB_Image...
153
new_array = new uchar[w() * h() * d()];
154
memcpy(new_array, array, w() * h() * d());
156
new_image = new Fl_RGB_Image(new_array, w(), h(), d(), ld());
157
new_image->alloc_array = 1;
160
} else return new Fl_RGB_Image(array, w(), h(), d(), ld());
145
162
if (W <= 0 || H <= 0) return 0;
147
164
// OK, need to resize the image data; allocate memory and
148
Fl_RGB_Image *new_image; // New RGB image
149
uchar *new_array, // New array for image data
150
*new_ptr; // Pointer into new array
165
uchar *new_ptr; // Pointer into new array
151
166
const uchar *old_ptr; // Pointer into old array
152
167
int c, // Channel number
153
168
sy, // Source coordinate
309
324
if (cy+H > h()) H = h()-cy;
310
325
if (H <= 0) return;
327
#ifdef __APPLE_QUARTZ__
328
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
329
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, w()*h()*d(), 0L);
330
id = CGImageCreate( w(), h(), 8, d()*8, ld()?ld():w()*d(),
331
lut, (d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
332
src, 0L, false, kCGRenderingIntentDefault);
333
CGColorSpaceRelease(lut);
334
CGDataProviderRelease(src);
312
336
id = fl_create_offscreen(w(), h());
313
337
fl_begin_offscreen((Fl_Offscreen)id);
314
338
fl_draw_image(array, 0, 0, w(), h(), d(), ld());
315
339
fl_end_offscreen();
317
340
if (d() == 2 || d() == 4) {
318
341
mask = fl_create_alphamask(w(), h(), d(), ld(), array);
330
354
fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
332
#elif defined(__APPLE__)
356
#elif defined(__APPLE_QD__)
335
359
// MRS: STR #114 says we should be using cx, cy, W, and H...
365
389
fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
391
#elif defined(__APPLE_QUARTZ__)
393
CGRect rect = { X, Y, W, H };
394
Fl_X::q_begin_image(rect, cx, cy, w(), h());
395
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
369
400
// I can't figure out how to combine a mask with existing region,