* Source/cairo/XGCairoSurface.m (-contentsOfScreen:inRect:):

Use the passed rect properly.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@33444 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2011-07-03 23:59:35 +00:00
parent 1d8df067f3
commit 407a90efc0
2 changed files with 17 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2011-07-03 Eric Wasylishen <ewasylishen@gmail.com>
* Source/cairo/XGCairoSurface.m (-contentsOfScreen:inRect:):
Use the passed rect properly.
2011-07-03 Eric Wasylishen <ewasylishen@gmail.com>
* Source/cairo/XGCairoSurface.m: Implementation of

View file

@ -99,13 +99,18 @@
if (XGetWindowAttributes(dpy, win, &attrs))
{
NSInteger width = rect.size.width;
NSInteger height = rect.size.height;
NSImage *result;
NSBitmapImageRep *bmp;
cairo_surface_t *src, *dest;
// Convert rect to flipped coordinates
rect.origin.y = attrs.height - NSMaxY(rect);
bmp = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
pixelsWide: attrs.width
pixelsHigh: attrs.height
pixelsWide: width
pixelsHigh: height
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
@ -116,11 +121,11 @@
bitsPerPixel: 32] autorelease];
src = cairo_xlib_surface_create(dpy, win, attrs.visual, attrs.width, attrs.height);
dest = cairo_image_surface_create_for_data([bmp bitmapData], CAIRO_FORMAT_ARGB32, attrs.width, attrs.height, [bmp bytesPerRow]);
dest = cairo_image_surface_create_for_data([bmp bitmapData], CAIRO_FORMAT_ARGB32, width, height, [bmp bytesPerRow]);
{
cairo_t *cr = cairo_create(dest);
cairo_set_source_surface(cr, src, 0, 0);
cairo_set_source_surface(cr, src, -1 * rect.origin.x, -1 * rect.origin.y);
cairo_paint(cr);
cairo_destroy(cr);
}
@ -137,9 +142,9 @@
stride = [bmp bytesPerRow];
cdata = [bmp bitmapData];
for (y = 0; y < attrs.height; y++)
for (y = 0; y < height; y++)
{
for (x = 0; x < attrs.width; x++)
for (x = 0; x < width; x++)
{
NSInteger i = (y * stride) + (x * 4);
unsigned char d = cdata[i];
@ -159,7 +164,7 @@
}
}
result = [[[NSImage alloc] initWithSize: NSMakeSize(attrs.width, attrs.height)] autorelease];
result = [[[NSImage alloc] initWithSize: NSMakeSize(width, height)] autorelease];
[result addRepresentation: bmp];
return result;
}