~ubuntu-branches/ubuntu/karmic/fltk1.1/karmic

« back to all changes in this revision

Viewing changes to src/Fl_Image.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-05-22 13:57:06 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050522135706-mchag24yf42lu7bu
Tags: 1.1.6-5
* Revert previous change, which seems to have been ineffective for some
  reason, in favor of commenting out the problematic Makefile rule
  altogether.  (Closes: #310151.)
* debian/control: Go back to specifying the URL as part of the
  description rather than via a non-standard field that doesn't seem to
  have caught on.  (Closes: #310240.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.32 2004/04/11 04:38:57 easysw Exp $"
 
2
// "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $"
3
3
//
4
4
// Image drawing code for the Fast Light Tool Kit (FLTK).
5
5
//
124
124
}
125
125
 
126
126
void Fl_RGB_Image::uncache() {
 
127
#ifdef __APPLE_QUARTZ__
 
128
  if (id)
 
129
    CGImageRelease((CGImageRef)id);
 
130
#else
127
131
  if (id) {
128
132
    fl_delete_offscreen((Fl_Offscreen)id);
129
133
    id = 0;
133
137
    fl_delete_bitmask((Fl_Bitmask)mask);
134
138
    mask = 0;
135
139
  }
 
140
#endif
136
141
}
137
142
 
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
 
146
 
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());
 
151
    if (array) {
 
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());
 
155
 
 
156
      new_image = new Fl_RGB_Image(new_array, w(), h(), d(), ld());
 
157
      new_image->alloc_array = 1;
 
158
 
 
159
      return new_image;
 
160
    } else return new Fl_RGB_Image(array, w(), h(), d(), ld());
144
161
  }
145
162
  if (W <= 0 || H <= 0) return 0;
146
163
 
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;
311
326
  if (!id) {
 
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);
 
335
#else
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();
316
 
 
317
340
    if (d() == 2 || d() == 4) {
318
341
      mask = fl_create_alphamask(w(), h(), d(), ld(), array);
319
342
    }
 
343
#endif
320
344
  }
321
345
#ifdef WIN32
322
346
  if (mask) {
329
353
  } else {
330
354
    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
331
355
  }
332
 
#elif defined(__APPLE__)
 
356
#elif defined(__APPLE_QD__)
333
357
  if (mask) {
334
358
    Rect src, dst;
335
359
    // MRS: STR #114 says we should be using cx, cy, W, and H...
364
388
  } else {
365
389
    fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
366
390
  }
 
391
#elif defined(__APPLE_QUARTZ__)
 
392
  if (id && fl_gc) {
 
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);
 
396
    Fl_X::q_end_image();
 
397
  }
367
398
#else
368
399
  if (mask) {
369
400
    // I can't figure out how to combine a mask with existing region,
397
428
 
398
429
 
399
430
//
400
 
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.32 2004/04/11 04:38:57 easysw Exp $".
 
431
// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.38 2004/09/24 16:00:10 easysw Exp $".
401
432
//