class GPixmap: public GPEnabled

RGB Color images.

Inheritance:


Public

[more] Construction.

[more] GPixmap()
Constructs an empty GBitmap object.
[more] GPixmap(int nrows, int ncolumns, GPixel *filler=0)
Constructs a GPixmap with nrows rows and ncolumns columns.
[more] GPixmap(const GBitmap &ref)
Constructs a GPixmap by copying the gray level image ref.
[more] GPixmap(const GBitmap &ref, const GRect &rect)
Constructs a GPixmap by copying the rectangle rect of the gray level image ref.
[more] GPixmap(const GPixmap &ref)
Copy constructors.
[more] GPixmap(const GPixmap &ref, const GRect &rect)
Constructs a GPixmap by copying the rectangle rect of the color image ref.
[more] GPixmap(ByteStream &ref)
Constructs a GPixmap by reading PPM data from ByteStream ref.

[more] Initialization.

[more]void init(int nrows, int ncolumns, GPixel *filler=0)
Resets the GPixmap to nrows rows and ncolumns columns.
[more]void init(const GPixmap &ref)
Resets the GPixmap by copying the size and the contents of the color image ref.
[more]void init(const GPixmap &ref, const GRect &rect)
Resets the GPixmap by copying the rectangle rect of the color image ref.
[more]void init(const GBitmap &ref, GPixel *ramp=0)
Resets the GPixmap by copying the size and the contents of the gray level image ref.
[more]void init(const GBitmap &ref, const GRect &rect, GPixel *ramp=0)
Resets the GPixmap by copying the rectangle rect of the gray level image ref.
[more]void init(ByteStream &ref)
Resets the GPixmap by reading PPM data from ByteStream ref.
[more]GPixmap& operator=(const GBitmap &ref)
Resets the GPixmap by copying the gray level image ref.
[more]GPixmap& operator=(const GPixmap &ref)
Copy operator.

[more] Accessing pixels.

[more]unsigned int rows() const
Returns the number of rows (the image height).
[more]unsigned int columns() const
Returns the number of columns (the image width).
[more]const GPixel* operator[] (int row) const
Returns a constant pointer to the first GPixel in row row.
[more]GPixel* operator[] (int row)
Returns a pointer to the first GPixel in row row.
[more]unsigned int rowsize() const
Returns the length (in pixels) of a row in memory.

[more] Resampling images.

[more]void downsample(const GPixmap *src, int factor, const GRect *rect=0)
Resets this GPixmap with a subsampled segment of color image src.
[more]void upsample(const GPixmap *src, int factor, const GRect *rect=0)
Resets this GPixmap with a oversampled segment of color image src.
[more]void downsample43(const GPixmap *src, const GRect *rect=0)
Resets this GPixmap with a rescaled segment of src (zoom 75%).
[more]void upsample23(const GPixmap *src, const GRect *rect=0)
Resets this GPixmap with a rescaled segment of src (zoom 150%).

[more] Blitting and applying stencils.

[more]void stencil(const GBitmap *bm, const GPixmap *pm, int pms=1, const GRect *pmr=0, double corr=1.0)
Paints the color image pm through the stencil bm into this image.

[more] Manipulating colors.

[more]void ordered_666_dither(int xmin=0, int ymin=0)
Dithers the image to 216 colors.
[more]void ordered_32k_dither(int xmin=0, int ymin=0)
Dithers the image to 32768 colors.
[more]void color_correct(double corr)
Applies a luminance gamma correction factor of corr.

[more] Miscellaneous.

[more]unsigned int get_memory_usage() const
Returns the number of bytes allocated for this image.
[more]void save_ppm(ByteStream &bs, int raw=1) const
Saves the image into ByteStream bs using the PPM format.

[more] Stealing or borrowing the memory buffer (advanced).

[more]GPixel* take_data(size_t &offset)
Steals the memory buffer of a GPixmap.
[more]void borrow_data(GPixel *data, int w, int h)
Initializes this GPixmap by borrowing a memory segment.


Inherited from GPEnabled:

Public Methods

oGPEnabled& operator=(const GPEnabled & obj)

Protected Fields

ovolatile int count

Protected Methods

ovirtual void destroy()


Documentation

RGB Color images. Instances of class GPixmap represent color images as a two dimensional array of pixels GPixel. The bracket operator returns a pointer to the pixels composing one line of the image. This pointer can be used as an array to read or write the pixels of this particular line. Following the general convention of the DjVu Reference Library, line zero is always the bottom line of the image.
o Construction.

o GPixmap()
Constructs an empty GBitmap object. The returned GPixmap has zero rows and zero columns. Use function init to change the size of the image.

o GPixmap(int nrows, int ncolumns, GPixel *filler=0)
Constructs a GPixmap with nrows rows and ncolumns columns. When the optional argument filler is specified, all pixels are initialized with the corresponding color.

o GPixmap(const GBitmap &ref)
Constructs a GPixmap by copying the gray level image ref. The constructed GPixmap has the same size as ref. The pixels are initialized with shades of grays copied from ref.

o GPixmap(const GBitmap &ref, const GRect &rect)
Constructs a GPixmap by copying the rectangle rect of the gray level image ref. The constructed GPixmap has the same size as rectangle rect. The pixels are initialized with shades of grays converted from the ink levels represented in ref. This conversion depends on the number of gray levels in ref.

o GPixmap(const GPixmap &ref)
Copy constructors. Constructs a GPixmap by replicating the size and the contents of GPixmap ref.

o GPixmap(const GPixmap &ref, const GRect &rect)
Constructs a GPixmap by copying the rectangle rect of the color image ref. The constructed GPixmap has the same size as rectangle rect. The pixels are initialized with colors copied from ref.

o GPixmap(ByteStream &ref)
Constructs a GPixmap by reading PPM data from ByteStream ref. See PNM and RLE file formats for more information.

o Initialization.

ovoid init(int nrows, int ncolumns, GPixel *filler=0)
Resets the GPixmap to nrows rows and ncolumns columns. When the optional argument filler is specified, all pixels are initialized with the corresponding color. The previous content of the GPixmap is discarded.

ovoid init(const GPixmap &ref)
Resets the GPixmap by copying the size and the contents of the color image ref. The previous content of the GPixmap is discarded.

ovoid init(const GPixmap &ref, const GRect &rect)
Resets the GPixmap by copying the rectangle rect of the color image ref. The previous content of the GPixmap is discarded.

ovoid init(const GBitmap &ref, GPixel *ramp=0)
Resets the GPixmap by copying the size and the contents of the gray level image ref. The optional argument ramp is an array of 256 pixel values used for mapping the gray levels to color values. Setting ramp to zero selects a linear ramp of shades of gray.

ovoid init(const GBitmap &ref, const GRect &rect, GPixel *ramp=0)
Resets the GPixmap by copying the rectangle rect of the gray level image ref. The optional argument ramp is an array of 256 pixel values used for mapping the gray levels to color values. Setting ramp to zero selects a linear ramp computed according to the maximal number of gray levels in ref.

ovoid init(ByteStream &ref)
Resets the GPixmap by reading PPM data from ByteStream ref. See PNM and RLE file formats for more information.

oGPixmap& operator=(const GBitmap &ref)
Resets the GPixmap by copying the gray level image ref. The pixels are initialized with shades of grays copied from ref.

oGPixmap& operator=(const GPixmap &ref)
Copy operator. Resets the GPixmap by copying the size and the contents of the color image ref. The previous content of the GPixmap is discarded.

o Accessing pixels.

ounsigned int rows() const
Returns the number of rows (the image height).

ounsigned int columns() const
Returns the number of columns (the image width).

oconst GPixel* operator[] (int row) const
Returns a constant pointer to the first GPixel in row row. This pointer can be used as an array to read the row elements.

oGPixel* operator[] (int row)
Returns a pointer to the first GPixel in row row. This pointer can be used as an array to read or write the row elements.

ounsigned int rowsize() const
Returns the length (in pixels) of a row in memory. This number is equal to the difference between pointers to pixels located in the same column in consecutive rows. This difference may be larger than the number of columns in the image.

o Resampling images.

ovoid downsample(const GPixmap *src, int factor, const GRect *rect=0)
Resets this GPixmap with a subsampled segment of color image src. This function conceptually rescales image src by a factor 1:factor, and copies rectangle rect of the subsampled image into the current GPixmap. The full subsampled image is copied if rect is a null pointer. Both operations are however performed together for efficiency reasons. Subsampling works by averaging the colors of the source pixels located in small squares of size factor times factor.

ovoid upsample(const GPixmap *src, int factor, const GRect *rect=0)
Resets this GPixmap with a oversampled segment of color image src. This function conceptually rescales image src by a factor factor:1, and copies rectangle rect of the oversampled image into the current GPixmap. The full oversampled image is copied if rect is a null pointer. Both operations are however performed together for efficiency reasons. Oversampling works by replicating the color of the source pixels into squares of size factor times factor.

ovoid downsample43(const GPixmap *src, const GRect *rect=0)
Resets this GPixmap with a rescaled segment of src (zoom 75%). This function conceptually rescales image src by a factor 3:4, and copies rectangle rect of the rescaled image into the current GPixmap. The full rescaled image is copied if rect is a null pointer. Both operations are however performed together for efficiency reasons. This function has been superseded by class GPixmapScaler.

ovoid upsample23(const GPixmap *src, const GRect *rect=0)
Resets this GPixmap with a rescaled segment of src (zoom 150%). This function conceptually rescales image src by a factor 3:2 and copies rectangle rect of the rescaled image into the current GPixmap. The full rescaled image is copied if rect is a null pointer. Both operations are however performed together for efficiency reasons. This function has been superseded by class GPixmapScaler.

o Blitting and applying stencils.
This function is essential for rendering DjVu images composed of multiple layers.

ovoid stencil(const GBitmap *bm, const GPixmap *pm, int pms=1, const GRect *pmr=0, double corr=1.0)
Paints the color image pm through the stencil bm into this image. This function conceptually computes an intermediate color image by first upsampling the GPixmap pm by a factor pms:1 (see upsample), extracting the sub-image designated by rectangle pmr if such a rectangle is specified, and applying color correction corr (see color_correct). This intermediate color image is then blended into the current GPixmap using the corresponding gray levels in GBitmap bm. All these four functions are however performed together for efficiency reasons.

Example: Assume that the current GPixmap already contains the color corrected background layer of a particular rectangle pmr for a DjVu image at a given target resolution. Assume that the GBitmap bm contains the corresponding region of the gray level mask layer at the same resolution. Assume finally that the GPixmap pm contains the low resolution foreground color layer for the complete DjVu image. This foreground color layer needs to be enlarged pms times to reach the target resolution. A single call to function stencil will render the DjVu image.

o Manipulating colors.

ovoid ordered_666_dither(int xmin=0, int ymin=0)
Dithers the image to 216 colors. This function applies an ordered dithering algorithm to reduce the image to 216 predefined colors. These predefined colors are located on a color cube of 6x6x6 colors: the color RGB coordinates can only take the following values: 0, 51, 102, 163, 214 or 255. This is useful for displaying images on a device supporting a maximum of 256 colors. Arguments xmin and ymin control the position of the dithering grids. This is useful for dithering tiled images. Arguments xmin and ymin must be the position of the bottom left corner of the tile contained in this GPixmap. Properly setting these arguments eliminates dithering artifacts on the tile boundaries.

ovoid ordered_32k_dither(int xmin=0, int ymin=0)
Dithers the image to 32768 colors. This function applies an ordered dithering algorithm to reduce the image to 32768 predefined colors. These predefined colors are located on a color cube of 32x32x32 colors: the color RGB coordinates can only take values in which the three least significant bits are set to 1. This is useful for displaying images with less than 24 bits per pixel. Arguments xmin and ymin control the position of the dithering grids. This is useful for dithering tiled images. Arguments xmin and ymin must be the position of the bottom left corner of the tile contained in this GPixmap. Properly setting these arguments eliminates dithering artifacts on the tile boundaries.

ovoid color_correct(double corr)
Applies a luminance gamma correction factor of corr. Values greater than 1.0 make the image brighter. Values smaller than 1.0 make the image darker. The documentation of program ppmcoco explains how to properly use this function. Note that standard gamma correction sharply increases the contrast of the darkest parts of the image. This effect reveals unpleasant data compression artifacts. This is why we use an ad-hoc formula which limits this effect. The resulting image is less accurate but more pleasant!

o Miscellaneous.

ounsigned int get_memory_usage() const
Returns the number of bytes allocated for this image.

ovoid save_ppm(ByteStream &bs, int raw=1) const
Saves the image into ByteStream bs using the PPM format. Argument raw selects the ``Raw PPM'' (1) or the ``Ascii PPM'' (0) format. See PNM and RLE file formats for more information.

o Stealing or borrowing the memory buffer (advanced).

oGPixel* take_data(size_t &offset)
Steals the memory buffer of a GPixmap. This function returns the address of the memory buffer allocated by this GPixmap object. The offset of the first pixel in the bottom line is written into variable offset. Other lines can be accessed using pointer arithmetic (see rowsize). The GPixmap object no longer ``owns'' the buffer: you must explicitly de-allocate the buffer using operator delete []. This de-allocation should take place after the destruction or the re-initialization of the GPixmap object. This function will return a null pointer if the GPixmap object does not ``own'' the buffer in the first place.

ovoid borrow_data(GPixel *data, int w, int h)
Initializes this GPixmap by borrowing a memory segment. The GPixmap then directly addresses the memory buffer data provided by the user. This buffer must be large enough to hold w*h GPixels. The GPixmap object does not ``own'' the buffer: you must explicitly de-allocate the buffer using operator delete []. This de-allocation should take place after the destruction or the re-initialization of the GPixmap object.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java