Gtk2

 view release on metacpan or  search on metacpan

xs/GdkImage.xs  view on Meta::CPAN


## not needed
# #ifndef GDK_DISABLE_DEPRECATED
# #define gdk_image_destroy              g_object_unref
# #endif /* GDK_DISABLE_DEPRECATED */


##-----------------------------------------------------------------------------
## Field accessors

GdkImageType
gdk_image_get_image_type (image)
	GdkImage *image

GdkVisual *
gdk_image_get_visual (image)
	GdkImage *image

GdkByteOrder
gdk_image_get_byte_order (image)
	GdkImage *image

gint
gdk_image_get_bytes_per_pixel (image)
	GdkImage *image
    ALIAS:
	get_bytes_per_line = 1
	get_bits_per_pixel = 2
	get_depth          = 3
	get_width          = 4
	get_height         = 5
    CODE:
	/* the guint16 fields expand to gint for RETVAL */
	switch (ix) {
	case 0:  RETVAL = gdk_image_get_bytes_per_pixel(image); break;
	case 1:  RETVAL = gdk_image_get_bytes_per_line(image);  break;
	case 2:  RETVAL = gdk_image_get_bits_per_pixel(image);  break;
	case 3:  RETVAL = gdk_image_get_depth(image);           break;
	case 4:  RETVAL = gdk_image_get_width(image);           break;
	default: /* case 5 */
		 RETVAL = gdk_image_get_height(image);          break;
	}
    OUTPUT:
	RETVAL

=for signature string = $image->get_pixels()
=for apidoc
Return a copy of the raw pixel data memory from C<$image>.  This is
C<bytes_per_line * height> many bytes.
=cut
## This is a copy similar to the way C<Gtk2::Gdk::Pixbuf> C<get_pixels>
## copies.  Perhaps in the future some sort of C<get_pixels_substr> could
## get just part of it, or C<put_bytes> or 4-arg substr write to part of it,
## as an alternative to individual C<get_pixel> / C<put_pixel>.
##
## A magic sv which could be read and written to modify the image data
## might be cute, but is probably more trouble than its worth.  substr
## fetch/store funcs would make it clearer what's being done.
##
## If a magic scalar held a reference then there's a gremlin in Perl
## 5.10 lvalue C<substr> where such an sv gets kept alive in the
## function scratchpad, risking the underlying GdkImage kept alive
## longer than it should be.  Or if it didn't hold a reference you'd
## have to rely on the application to keep the GdkImage alive while
## the raw memory was being manipulated.
##
SV *
gdk_image_get_pixels (image)
	GdkImage *image
    CODE:
        /* Crib note: memory block size is "bytes_per_line * height" per the
           shmget() or malloc() in _gdk_image_new_for_depth() of
           gdkimage-x11.c */
	RETVAL = newSVpv ((char *) image->mem, image->bpl * image->height);
    OUTPUT:
	RETVAL



( run in 0.576 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )