Package: gdk-pixbuf

Class gdk-pixbuf

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

bits-per-sample
The bits-per-sample property of type :int (Read / Write / Construct Only)
The number of bits per sample. Currently only 8 bit per sample are supported.
Allowed values: [1,16]
Default value: 8
colorspace
The colorspace property of type gdk-colorspace (Read / Write / Construct Only)
The colorspace in which the samples are interpreted.
Default value: :rgb
has-alpha
The has-alpha property of type :boolean (Read / Write / Construct Only)
Whether the pixbuf has an alpha channel.
Default value: false
height
The height property of type :int (Read / Write / Construct Only)
The number of rows of the pixbuf.
Allowed values: >= 1
Default value: 1
n-channels
The n-channels property of type :int (Read / Write / Construct Only)
The number of samples per pixel. Currently, only 3 or 4 samples per pixel are supported.
Allowed values: >= 0
Default value: 3
pixel-bytes
The pixel-bytes property of type GBytes (Read / Write / Construct Only)
Readonly pixel data.
pixels
The pixels property of type :pointer (Read / Write / Construct Only)
A pointer to the pixel data of the pixbuf.
rowstride
The rowstride property of type :int (Read / Write / Construct Only)
The number of bytes between the start of a row and the start of the next row. This number must be at least as large as the width of the pixbuf.
Allowed values: >= 1
Default value: 1
width
The width property of type :int (Read / Write / Construct Only)
The number of columns of the pixbuf.
Allowed values: >= 1
Default value: 1

Details

The gdk-pixbuf object contains information that describes an image in memory. It contains information about the image's pixel data, its color space, bits per sample, width and height, and the rowstride (the number of bytes between the start of one row and the start of the next).

Image Data

Image data in a pixbuf is stored in memory in uncompressed, packed format. Rows in the image are stored top to bottom, and in each row pixels are stored from left to right. There may be padding at the end of a row. The "rowstride" value of a pixbuf, as returned by the gdk-pixbuf-rowstride function, indicates the number of bytes between rows.

Examples

The following code illustrates a simple put-pixel function for RGB pixbufs with 8 bits per channel with an alpha channel. It is not included in the gdk-pixbuf library for performance reasons. Rather than making several function calls for each pixel, your own code can take shortcuts.
(defun put-pixel (pixbuf x y red green blue alpha)
  (let ((n-channels (gdk-pixbuf-n-channels pixbuf))
        (rowstride (gdk-pixbuf-rowstride pixbuf))
        (pixels (gdk-pixbuf-pixels pixbuf)))
    ;; Add offset to the pointer pixels into the pixbuf
    (incf-pointer pixels (+ (* y rowstride) (* x n-channels)))
    ;; Set the color of the point and the alpha value
    (setf (mem-aref pixels :uchar 0) red)
    (setf (mem-aref pixels :uchar 1) green)
    (setf (mem-aref pixels :uchar 2) blue)
    (setf (mem-aref pixels :uchar 3) alpha)))    
This function will not work for pixbufs with images that are other than 8 bits per sample or channel, but it will work for most of the pixbufs that GTK+ uses.

Note

If you are doing memcpy() of raw pixbuf data, note that the last row in the pixbuf may not be as wide as the full rowstride, but rather just as wide as the pixel data needs to be. That is, it is unsafe to do memcpy (dest, pixels, rowstride * height) to copy a whole pixbuf. Use the gdk-pixbuf-copy function instead, or compute the width in bytes of the last row as width * ((n_channels * bits_per_sample + 7) / 8).
 

Slot Access Functions

Inherited Slot Access Functions

2021-12-12