![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
An Image is a rectangular array of pixels. More...
#include <FXImage.h>
Public Member Functions | |
| FXImage (FXApp *a, const FXColor *pix=NULL, FXuint opts=0, FXint w=1, FXint h=1) | |
| Create an image. | |
| void | setOptions (FXuint opts) |
| Change options. | |
| FXuint | getOptions () const |
| To get to the option flags. | |
| void | setOwned (FXbool owned) |
| Set pixel data ownership flag. | |
| FXbool | isOwned () const |
| Get pixel data ownership flag. | |
| virtual void | setData (FXColor *pix, FXuint opts=0) |
| Populate the image with new pixel data of the same size; it will assume ownership of the pixel data if image IMAGE_OWNED option is passed. | |
| virtual void | setData (FXColor *pix, FXuint opts, FXint w, FXint h) |
| Populate the image with new pixel data of a new size; it will assume ownership of the pixel data if image IMAGE_OWNED option is passed. | |
| FXColor * | getData () const |
| Return pointer to the pixel data of the image. | |
| FXColor | getPixel (FXint x, FXint y) const |
| Get pixel at x,y. | |
| void | setPixel (FXint x, FXint y, FXColor color) |
| Change pixel at x,y. | |
| FXbool | hasAlpha () const |
| Scan the image and return false if fully opaque. | |
| virtual void | create () |
| Create the server side pixmap, then call render() to fill it with the pixel data from the client-side buffer. | |
| virtual void | detach () |
| Detach the server side pixmap from the Image. | |
| virtual void | destroy () |
| Destroy the server-side pixmap. | |
| virtual void | restore () |
| Retrieves pixels from the server-side image. | |
| virtual void | render () |
| Render the server-side representation of the image from client-side pixels. | |
| virtual void | release () |
| Release the client-side pixels buffer, free it if it was owned. | |
| virtual void | resize (FXint w, FXint h) |
| Resize both client-side and server-side representations (if any) to the given width and height. | |
| virtual void | scale (FXint w, FXint h, FXint quality=0) |
| Rescale pixels image to the specified width and height; this calls resize() to adjust the client and server side representations. | |
| virtual void | mirror (FXbool horizontal, FXbool vertical) |
| Mirror image horizontally and/or vertically. | |
| virtual void | rotate (FXint degrees) |
| Rotate image by degrees ccw; this calls resize() to adjust the client and server side representations if necessary. | |
| virtual void | crop (FXint x, FXint y, FXint w, FXint h, FXColor color=0) |
| Crop image to given rectangle; this calls resize() to adjust the client and server side representations. | |
| virtual void | fill (FXColor color) |
| Fill image with uniform color. | |
| virtual void | fade (FXColor color, FXint factor=255) |
| Fade image to uniform color. | |
| virtual void | xshear (FXint shear, FXColor clr=0) |
| Shear image horizontally; the number of pixels is equal to the shear parameter times 256. | |
| virtual void | yshear (FXint shear, FXColor clr=0) |
| Shear image vertically; the number of pixels is equal to the shear parameter times 256. | |
| virtual void | hgradient (FXColor left, FXColor right) |
| Fill horizontal gradient. | |
| virtual void | vgradient (FXColor top, FXColor bottom) |
| Fill vertical gradient. | |
| virtual void | gradient (FXColor topleft, FXColor topright, FXColor bottomleft, FXColor bottomright) |
| Fill with gradient. | |
| virtual void | blend (FXColor color) |
| Blend image over uniform color. | |
| virtual void | invert () |
| Invert colors of an image. | |
| virtual void | colorize (FXColor color) |
| Colorize image based on luminance. | |
| virtual FXbool | savePixels (FXStream &store) const |
| Save pixel data only. | |
| virtual FXbool | loadPixels (FXStream &store) |
| Load pixel data only. | |
| virtual void | save (FXStream &store) const |
| Save object to stream. | |
| virtual void | load (FXStream &store) |
| Load object from stream. | |
| virtual | ~FXImage () |
| Destructor. | |
Protected Attributes | |
| FXColor * | data |
| FXuint | options |
Friends | |
| class | FXDC |
| class | FXDCWindow |
An Image is a rectangular array of pixels.
It supports two representations of these pixels: a client-side pixel buffer which is stored as an array of FXColor, and a server-side pixmap which is stored in an organization directly compatible with the screen, for fast drawing onto the device. The server-side representation is not directly accessible from the current process as it lives in the process of the X Server or GDI. Before the image can be used in drawing operations, the server-side representation of the image must be realized by calling create(); until this is done, only the client-side pixel buffer exists. Usually the client-side pixel buffer is released when the server-side representation is generated [thus saving substantial amounts of memory when only the server-resident part of the image is of interest]. But if further manipulation of the client-side pixel buffer is needed, the IMAGE_KEEP option can be passed. In that case, the client-side buffer can be modified, and the server-side pixmap can be updated by calling render().
| FX::FXImage::FXImage | ( | FXApp * | a, |
| const FXColor * | pix = NULL, |
||
| FXuint | opts = 0, |
||
| FXint | w = 1, |
||
| FXint | h = 1 |
||
| ) |
Create an image.
If a client-side pixel buffer has been specified, the image does not own the pixel buffer unless the IMAGE_OWNED flag is set. If the IMAGE_OWNED flag is set but a NULL pixel buffer is passed, a pixel buffer will be automatically created and will be owned by the image. The flags IMAGE_SHMI and IMAGE_SHMP may be specified for large images to instruct render() to use shared memory to communicate with the server.
| virtual void FX::FXImage::create | ( | ) | [virtual] |
Create the server side pixmap, then call render() to fill it with the pixel data from the client-side buffer.
After the server-side image has been created, the client-side pixel buffer will be deleted unless IMAGE_KEEP has been specified. If the pixel buffer is not owned, i.e. the flag IMAGE_OWNED is not set, the pixel buffer will not be deleted, however the pixel buffer will be set to NULL.
Reimplemented from FX::FXId.
Reimplemented in FX::FXIcon.
| virtual void FX::FXImage::crop | ( | FXint | x, |
| FXint | y, | ||
| FXint | w, | ||
| FXint | h, | ||
| FXColor | color = 0 |
||
| ) | [virtual] |
Crop image to given rectangle; this calls resize() to adjust the client and server side representations.
The new image may be smaller or larger than the old one; blank areas are filled with color. There must be at least one pixel of overlap between the old and the new image.
| virtual void FX::FXImage::destroy | ( | ) | [virtual] |
Destroy the server-side pixmap.
The client-side pixel buffer is not affected.
Reimplemented from FX::FXId.
Reimplemented in FX::FXIcon.
| virtual void FX::FXImage::detach | ( | ) | [virtual] |
Detach the server side pixmap from the Image.
Afterwards, the Image is left as if it never had a server-side resources.
Reimplemented from FX::FXId.
Reimplemented in FX::FXIcon.
| virtual void FX::FXImage::release | ( | ) | [virtual] |
Release the client-side pixels buffer, free it if it was owned.
If it is not owned, the image just forgets about the buffer.
| virtual void FX::FXImage::render | ( | ) | [virtual] |
Render the server-side representation of the image from client-side pixels.
Normally, IMAGE_DITHER is used which causes the server-side representation to be rendered using a 16x16 ordered dither if necessary; however if IMAGE_NEAREST is used a faster (but uglier-looking), nearest neighbor algorithm is used.
Reimplemented in FX::FXIcon.
| virtual void FX::FXImage::resize | ( | FXint | w, |
| FXint | h | ||
| ) | [virtual] |
Resize both client-side and server-side representations (if any) to the given width and height.
The new representations typically contain garbage after this operation and need to be re-filled.
Reimplemented from FX::FXDrawable.
Reimplemented in FX::FXIcon.
| virtual void FX::FXImage::restore | ( | ) | [virtual] |
Retrieves pixels from the server-side image.
For example, to make screen snapshots, or to retrieve an image after it has been drawn into by various means.
| virtual void FX::FXImage::setData | ( | FXColor * | pix, |
| FXuint | opts = 0 |
||
| ) | [virtual] |
Populate the image with new pixel data of the same size; it will assume ownership of the pixel data if image IMAGE_OWNED option is passed.
The server-side representation of the image, if it exists, is not updated. This can be done by calling render().
| virtual void FX::FXImage::setData | ( | FXColor * | pix, |
| FXuint | opts, | ||
| FXint | w, | ||
| FXint | h | ||
| ) | [virtual] |
Populate the image with new pixel data of a new size; it will assume ownership of the pixel data if image IMAGE_OWNED option is passed.
The size of the server- side representation of the image, if it exists, is adjusted but the contents are not updated yet. This can be done by calling render().
| virtual void FX::FXImage::xshear | ( | FXint | shear, |
| FXColor | clr = 0 |
||
| ) | [virtual] |
Shear image horizontally; the number of pixels is equal to the shear parameter times 256.
The area outside the image is filled with transparent black, unless another color is specified.
| virtual void FX::FXImage::yshear | ( | FXint | shear, |
| FXColor | clr = 0 |
||
| ) | [virtual] |
Shear image vertically; the number of pixels is equal to the shear parameter times 256.
The area outside the image is filled with transparent black, unless another color is specified.
|
|