- // create a CGImage from those bits
-
- CGDataProviderRef prov =
- CGDataProviderCreateWithData (NULL, data, bpl * nsfrom.size.height,
- NULL);
- cgi = CGImageCreate (src_rect.size.width, src_rect.size.height,
- bps, bpp, bpl,
- dpy->colorspace,
- /* Use whatever default bit ordering we got from
- initWithFocusedViewRect. I would have assumed
- that it was (kCGImageAlphaNoneSkipFirst |
- kCGBitmapByteOrder32Host), but on Intel,
- it's not!
- */
- 0,
- prov,
- NULL, /* decode[] */
- NO, /* interpolate */
- kCGRenderingIntentDefault);
- //Assert (CGImageGetColorSpace (cgi) == dpy->colorspace, "bad colorspace");
- CGDataProviderRelease (prov);
+ // If we are copying from a Window to a Pixmap, we must first copy
+ // the bits to an intermediary CGImage object, then copy that to the
+ // Pixmap's CGContext.
+ //
+ NSBitmapImageRep *bm = [[NSBitmapImageRep alloc]
+ initWithFocusedViewRect:nsfrom];
+ unsigned char *data = [bm bitmapData];
+ int bps = [bm bitsPerSample];
+ int bpp = [bm bitsPerPixel];
+ int bpl = [bm bytesPerRow];
+ releaseme = bm;
+
+ // create a CGImage from those bits.
+ // (As of 10.5, we could just do cgi = [bm CGImage] (it is autoreleased)
+ // but that method didn't exist in 10.4.)
+
+ CGDataProviderRef prov =
+ CGDataProviderCreateWithData (NULL, data, bpl * nsfrom.size.height,
+ NULL);
+ cgi = CGImageCreate (src_rect.size.width, src_rect.size.height,
+ bps, bpp, bpl,
+ dpy->colorspace,
+ /* Use whatever default bit ordering we got from
+ initWithFocusedViewRect. I would have assumed
+ that it was (kCGImageAlphaNoneSkipFirst |
+ kCGBitmapByteOrder32Host), but on Intel,
+ it's not!
+ */
+ 0,
+ prov,
+ NULL, /* decode[] */
+ NO, /* interpolate */
+ kCGRenderingIntentDefault);
+ free_cgi_p = YES;
+ //Assert(CGImageGetColorSpace(cgi) == dpy->colorspace,"bad colorspace");
+ CGDataProviderRelease (prov);
+ }