Crea  Modifica  FrontPage  Indici  Cerca  Ultime modifiche  History  RSS  Login


class Gdk::Pixdata

A Gdk::Pixdata contains pixbuf information in a form suitable for serialization and streaming.

Class Methods

Deserializes (reconstruct) a Gdk::Pixdata from a byte stream(Array). The byte stream consists of a straightforward writeout of the Gdk::Pixdata fields in network byte order, plus the pixel_data bytes the structure points to. The pixdata contents are reconstructed byte by byte and are checked for validity. This method may raises Gdk::PixbufError::CORRUPT_IMAGE or Gdk::PixbufError::UNKNOWN_TYPE.
  • stream: stream of bytes containing a serialized Gdk::Pixdata structure(Array of Integer).
  • Returns: a newly-allocated Gdk::Pixdata.
Gdk::Pixdata.from_pixbuf(pixbuf, use_rle)
Converts a Gdk::Pixbuf to a Gdk::Pixdata. If use_rle is true, the pixel data is run-length encoded into newly-allocated memory.
  • pixbuf: the data to fill pixdata with.
  • use_rle: true if it uses run-length encoding for the pixel data, or false.
  • Returns: If ure_rle is true, the newly-allocated Gdk::Pixdata, or Gdk::Pixdata.

Instance Methods

Serializes a Gdk::Pixdata into a byte stream(Array). The byte stream consists of a straightforward writeout of the Gdk::Pixdata fields in network byte order, plus the pixel_data bytes the structure points to.
  • Returns: A newly-allocated Array containing the serialized Gdk::Pixdata structure.
Converts a Gdk::Pixdata to a Gdk::Pixbuf. If copy_pixels is true or if the pixel data is run-length-encoded, the pixel data is copied into newly-allocated memory; otherwise it is reused. If failure, it raises an Gdk::PixbufError.
  • copy_pixels: true if it copies raw pixel data; run-length encoded pixel data is always copied.
  • Returns: a new Gdk::Pixbuf
to_csource(name, dump_type)
Generates C source code suitable for compiling images directly into programs. GTK+ ships with a program called gdk-pixbuf-csource which offers a command line interface to this method.
  • name: used for naming generated data structures or macros.
  • dump_type: a GdkPixdataDumpType determining the kind of C source to be generated.
  • Returns: a newly-allocated string containing the C source form of pixdata.
Magic number. A valid Gdk::Pixdata must have Gdk::Pixdata::PIXBUF_MAGIC_NUMBER here.
  • Returns: magic number
Less than 1 to disable length checks, otherwise the length of pixel_data.
  • Returns: length
Information about colorspace, sample width and encoding, in a GdkPixdataType.
  • Returns: pixdata_type
Distance in bytes between rows.
  • Returns: rowstride
Width of the image in pixels.
  • Returns: width
Height of the image in pixels.
  • Returns: height
width x height pixels, encoded according to pixdata_type and rowstride.
  • Returns: pixel_data



An enumeration containing three sets of flags for a GdkPixdata struct: one for the used colorspace, one for the width of the samples and one for the encoding of the pixel data.

= 0x01. Each pixel has red, green and blue samples.
= 0x02. Each pixel has red, green and blue samples and an alpha value.
= 0xff. Mask for the colortype flags of the enum.
= 0x01 << 16. Each sample has 8 bits.
= 0x0f << 16. Mask for the sample width flags of the enum.
= 0x01 << 24. The pixel data is in raw form.
= 0x02 << 24. The pixel data is run-length encoded. Runs may be up to 127 bytes long; their length is stored in a single byte preceding the pixel data for the run. If a run is constant, its length byte has the high bit set and the pixel data consists of a single pixel which must be repeated.
= 0x0f << 24. Mask for the encoding flags of the enum.


An enumeration which is used by Gdk::Pixdata#to_csource to determine the form of C source to be generated. The three values Gdk::Pixdata::DUMP_PIXDATA_STREAM, Gdk::Pixdata::DUMP_PIXDATA_STRUCT and Gdk::Pixdata::DUMP_MACROS are mutually exclusive, as are Gdk::Pixdata::DUMP_GTYPES and Gdk::Pixdata::DUMP_CTYPES. The remaining elements are optional flags that can be freely added.

= 0. Generate pixbuf data stream (a single string containing a serialized Gdk::Pixdata structure in network byte order).
= 1. Generate GdkPixdata structure (needs the GdkPixdata structure definition from gdk-pixdata.h).
= 2. Generate *_ROWSTRIDE, *_WIDTH, *_HEIGHT, *_BYTES_PER_PIXEL and *_RLE_PIXEL_DATA or *_PIXEL_DATA macro definitions for the image.
= 0. Generate GLib data types instead of standard C data types.
= 1 << 8. Generate standard C data types instead of GLib data types.
= 1 << 9. Generate static symbols.
= 1 << 10. Generate const symbols.
= 1 << 16. Provide a *_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) macro definition to decode run-length encoded image data.


= 'GdkP'. Magic number for Gdk::Pixdata structures.
= (4 + 4 + 4 + 4 + 4 + 4). The length of a Gdk::Pixdata structure without the pixel_data pointer.


2006-04-23: Fixed the content of Gdk::Pixdata#length. - Masao

Ultima modifica:2006/04/23 00:40:30
Parola chiave: