Raster is an abstract class representing raster image. Example of Raster derived classes is PngRaster, that serves as .png image file decoder or MemoryRaster, that represent image in memory that can be in specific format (not RGBA).
Raster provides basic information about image (GetSize and GetInfo returning Raster::Info) and is a source of image scanlines. Scanlines are returned as Raster::Line objects. If possible, Raster derived classes should attempt to minimize memory requirements. For example, PngRaster only fetches individual scanline from the file at time, if possible.
This class represents a single scanline in the raster. For performance reasons, it uses pick transfer semantics. As is can be used both is situations where referenced data are stored in Raster or in situations where they need custom storage, constructors have 'free' parameter. Scanline can be represented in format of Raster or as RGBA array. Conversion to RGBA array is lazy - does not happen until it is needed.
Note that Line is only valid as long as its source Raster exists.
For convenience, this class is also typedefed as RasterLine.
Raster::Line Public Method List
const RGBA *GetRGBA() const
Returns a pointer to array with scanline pixels. Conversion of Raster format to RGBA buffer is lazy, does not happen before this function is called for the first time. Also, if Raster format is RGBA, no conversion is performed and pointer to raw data is returned.
const byte *GetRawData() const
Returns the scanline in Raster format.
operator const RGBA *() const
const RGBA *operator~() const
Raster::Line Constructor detail
Line(const RGBA *data, bool free)
Constructs Line from RGBA data. If free is true, Line destructor deletes the data pointer.
Line(const byte *fmtdata, Raster *raster, bool fmtfree)
Constructs Line from data fmtdata in format of raster. If fmtfree.is true, Line destructor deletes the fmtdata pointer.
Line(pick_ Line& b)
Default constructor. Default constructed Line can be used as target of pick transfer from another Line.
void operator=(pick_ Line& b)
This structure is used to provide the information about Raster. For convenience, this class is also typedefed as RasterInfo.
Raster::Line Member Variables
Number of bits per pixel. Default value is 24.
Number of colors. Default value is 16777216.
Physical size of source image, e.g. for scanned images, in 1/600 inches. Size(0, 0) if not known (default value).
Hotspot location. If not know or there is none, Point(0, 0) (default value).
The kind of image, one of IMAGE_EMPTY, IMAGE_ALPHA, IMAGE_MASK, IMAGE_OPAQUE. Default value is IMAGE_OPAQUE.
Orientation of image. This is one of FLIP_NONE, FLIP_MIRROR_HORZ, FLIP_ROTATE_180, FLIP_MIRROR_VERT, FLIP_TRANSPOSE, FLIP_ROTATE_CLOCKWISE, FLIP_TRANSVERSE, FLIP_ROTATE_ANTICLOCKWISE. This value is intended to flip Image to correct orientation (usually JPEG from digital camera).
virtual void SeekPage(int page)
Provides Raster with ability to handle sources that contain more than single image (e.g. animated GIFs). Sets Raster to image no page, first image is 0. Default implementation is empty.
virtual int GetPageCount()
Returns a number of images in Raster. Default implementation returns 1.
virtual bool Create()
Called at the beginning of processing of a new raster, e.g. used to read file header and get internal variables ready for processing. false return value indicates failure.
virtual Size GetSize() = 0
Returns the size of Raster in pixels.
virtual Info GetInfo()
Returns the information about Raster.
virtual Line GetLine(int line) = 0
Reads a single scanline line from the raster. If possible, Raster should be optimized for reading scanlines in ascending order - this what most processing functions (should) require.
virtual bool IsError()
Signals that during the Raster processing, there was an error. For example, it can signal that .png file is corrupt.
virtual int GetPaletteCount()
Returns the size of palette for raster. If there is no palette, returns 0.
virtual const RGBA *GetPalette()
Returns current palette, NULL if there is no palette.
virtual const RasterFormat *GetFormat()
Returns the format of Raster, can return NULL if format is RGBA.
Same as GetSize().cx.
Same as GetSize().cy.
Line operator(int i)
Same as GetLine(i).
Image GetImage(int x, int y, int cx, int cy, const Gate2<int, int> progress = false)
Image GetImage(const Gate2<int, int> progress = false)
Converts area x,y,cx,cy, or the whole Rater, to Image. Parameter progress.can be used to trace the progress of operation (first int is current step, second is number of step to do) and also to cancel the operation (if it returns true; empty Image is returned in that case). Default value for the parameter means no progress feedback is provided.