forked from AuroraMiddleware/gtk
Implement copying from a window, part of bug #348493.
2007-05-25 Richard Hult <richard@imendio.com> * gdk/quartz/gdkimage-quartz.c: (_gdk_quartz_image_copy_to_image): Implement copying from a window, part of bug #348493. svn path=/trunk/; revision=17917
This commit is contained in:
parent
cb18766ac5
commit
caab6d9737
@ -1,3 +1,8 @@
|
||||
2007-05-25 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkimage-quartz.c: (_gdk_quartz_image_copy_to_image):
|
||||
Implement copying from a window, part of bug #348493.
|
||||
|
||||
2007-05-25 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkprintoperation-unix.c (unix_end_run): Hold a
|
||||
|
@ -36,8 +36,67 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return NULL;
|
||||
GdkScreen *screen;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_QUARTZ (drawable), NULL);
|
||||
g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL);
|
||||
|
||||
screen = gdk_drawable_get_screen (drawable);
|
||||
if (!image)
|
||||
image = _gdk_image_new_for_depth (screen, GDK_IMAGE_FASTEST, NULL,
|
||||
width, height,
|
||||
gdk_drawable_get_depth (drawable));
|
||||
|
||||
if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))
|
||||
{
|
||||
g_warning ("Copying a pixmap to an image is not implemented yet.");
|
||||
}
|
||||
else if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
{
|
||||
GdkQuartzView *view;
|
||||
NSBitmapImageRep *rep;
|
||||
NSRect rect;
|
||||
guchar *data;
|
||||
int x, y;
|
||||
NSSize size;
|
||||
|
||||
view = GDK_WINDOW_IMPL_QUARTZ (drawable)->view;
|
||||
|
||||
/* We return the image even if we can't copy to it. */
|
||||
if (![view lockFocusIfCanDraw])
|
||||
return image;
|
||||
|
||||
rect = NSMakeRect (src_x, src_y, width, height);
|
||||
|
||||
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: rect];
|
||||
[view unlockFocus];
|
||||
|
||||
data = [rep bitmapData];
|
||||
size = [rep size];
|
||||
|
||||
for (y = 0; y < size.height; y++)
|
||||
{
|
||||
guchar *src = data + y * [rep bytesPerRow];
|
||||
|
||||
for (x = 0; x < size.width; x++)
|
||||
{
|
||||
gint32 pixel;
|
||||
|
||||
if (image->byte_order == GDK_LSB_FIRST)
|
||||
pixel = src[0] << 8 | src[1] << 16 |src[2] << 24;
|
||||
else
|
||||
pixel = src[0] << 16 | src[1] << 8 |src[2];
|
||||
|
||||
src += 3;
|
||||
|
||||
gdk_image_put_pixel (image, dest_x + x, dest_y + y, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
[rep release];
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user