![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
Pixel order: BGRA
Represents a raster in raw pixel form that can be drawn using a TSLRenderingInterface. This class is intended to assist applications that draw application-generated dynamic rasters as part of custom rendering by allowing integration with other MapLink rendering operations.
This class should not be used to draw rasters that do not change frequently, these should be loaded into a TSLRasterDataLayer instead.
This class cannot be created directly. Applications should create this object by using TSLDrawingSurface::createRasterBuffer or TSLRenderingInterface::createRasterBuffer. The raster object is associated with the drawing surface it was created from, and should be deleted before the drawing surface.
The contents of the raster can be set and updated in the following fashion:
TSLRasterBuffer *raster = surface->createRasterBuffer( width, height, format ); unsigned char *imageData = raster->mapRasterData( TSLRasterBuffer::Write );
// Write data to imageData
raster->unmapRasterData();
// The raster is now populated.
The raster can be drawn using TSLRenderingInterface::drawRaster.
Due to the underlying drawing technology used, rasters will always have a pixelStride value of 4. Rasters using the Greyscale and RGB24 formats therefore use the same amount of memory as those in RGBA32 format.
Rasters may be shared between different TSLMotifSurfaces that are connected to the same X server. It is the application's responsibility to manage synchronisation if the drawing surfaces use different display connections.
This class is not currently implemented for this drawing surface.
This class is not currently implemented for this drawing surface.
Public Types | |
enum | MapAction { Read = 0x1 , Write = 0x2 } |
enum | Format { Greyscale , RGB24 , RGBA32 } |
enum | FilterMode { Nearest , Linear } |
Public Member Functions | |
~TSLRasterBuffer () | |
void | brightness (int value) |
int | brightness () const |
void | contrast (int value) |
int | contrast () const |
void | gamma (int value) |
int | gamma () const |
unsigned int | height () const |
Format | format () const |
unsigned char * | mapRasterData (int useType=Write) |
unsigned int | pixelStride () const |
unsigned int | rowStride () const |
void | transparency (unsigned char value) |
unsigned char | transparency () const |
void | unmapRasterData () |
unsigned int | width () const |
void | operator delete (void *self) |
Defines the types of image filtering that can be used when drawing a TSLRasterBuffer.
The available values are:
Nearest : The image will be drawn using nearest neighbour filtering. Depending on the type of drawing surface this may be faster than Linear.
Linear : The image will be drawn using linear or bi-linear filtering dependent on the type of drawing surface the raster was created from.
Enumerator | |
---|---|
Nearest | |
Linear |
Defines the available types of image formats that a TSLRasterBuffer can represent. The available types are:
Greyscale : The raster is a greyscale image, with a single channel of 8 bits per pixel. RGB24 : The raster is an RGB image with 8 bits per colour channel. RGBA32 : The raster is an RGBA image with 8 bits per colour channel.
Enumerator | |
---|---|
Greyscale | |
RGB24 | |
RGBA32 |
Defines the set of actions that will be performed on the memory block returned from TSLRasterBuffer::mapRasterData.
The available values are:
Read : The application will read pixel values from the mapped memory block.
Write : The application will write pixel values to the mapped memory block.
Enumerator | |
---|---|
Read | |
Write |
TSLRasterBuffer::~TSLRasterBuffer | ( | ) |
int TSLRasterBuffer::brightness | ( | ) | const |
Returns the current brightness adjustment value used when drawing the raster.
void TSLRasterBuffer::brightness | ( | int | value | ) |
Sets the brightness adjustment to use when drawing the raster. Increases or decreases the luminance of all pixels.
Valid values are from -1000 (minimum brightness) to 1000 (maximum brightness).
A value of 0 means no brightness adjustment.
The default value is 0.
value | The brightness adjustment to use when drawing the raster. |
int TSLRasterBuffer::contrast | ( | ) | const |
Returns the current contrast adjustment value used when drawing the raster.
void TSLRasterBuffer::contrast | ( | int | value | ) |
Sets the contrast adjustment to use when drawing the raster. Increases or decreases the range between black and white pixels.
Valid values are from -1000 (no contrast) to 1000 (maximum contrast).
A value of 0 means no contrast adjustment.
The default value is 0.
value | The contrast adjustment to use when drawing the raster. |
Format TSLRasterBuffer::format | ( | ) | const |
Returns the base format of the raster. This determines how the data in the raster is interpreted when drawing.
int TSLRasterBuffer::gamma | ( | ) | const |
Returns the current gamma correction applied when drawing the raster.
void TSLRasterBuffer::gamma | ( | int | value | ) |
Sets the gamma correction to use when drawing the raster. This applies a nonlinear correction according to the standard gamma equation.
The value is a positive integer which is 100 times the required gamma value, e.g. to achieve a gamma correction of 0.15, set a value of 15.
A value of 100 means no gamma correction.
The default value is 100.
value | The gamma correction to apply when drawing the raster. |
unsigned int TSLRasterBuffer::height | ( | ) | const |
Returns the height of the raster.
unsigned char * TSLRasterBuffer::mapRasterData | ( | int | useType = Write | ) |
Returns a pointer to the internal image data that can be used to update the contents of the raster.
The structure of the returned pointer must be interpreted according to the format of the image and the values returned from rowStride and pixelStride methods. The memory block is always height() * rowStride() bytes in size.
The useType specified when calling this method is a bitmask of the values from the MapAction enumeration. These define the actions that will be performed on the memory block, thus the valid combinations are Read, Write and Read | Write. The results of performing an action on the memory block without specifying the corresponding flag (e.g. writing to a block mapped with only the Read flag set) is undefined.
The memory block must be unmapped by calling unmapRasterData() before the image can be drawn.
The initial contents of the raster is undefined.
If the application will not read the contents of the returned memory block then it is more efficient to only specify the Write flag. In this case the contents of the returned data is undefined and the entire raster must be respecified.
The order of colour channels in the returned data block for RGB and RGBA formats is dependent on the drawing surface that this raster was created from. For a memory block mapped in the following fashion this is as follows:
unsigned char *pixelData = raster->mapRasterData( TSLRasterBuffer::Write );
Image data is interpreted in the same fashion as an LSB first ARGB XImage. This means that channels are in BGRA order from the first byte, i.e.
pixelData[0] = blue pixelData[1] = green pixelData[2] = red pixelData[3] = alpha when format() is RGBA32, unused otherwise.
useType | A bitfield of the actions that will be performed on the returned memory block. The available actions are defined by the MapAction enumeration. |
void TSLRasterBuffer::operator delete | ( | void * | self | ) |
unsigned int TSLRasterBuffer::pixelStride | ( | ) | const |
Returns the stride in bytes between individual pixels on one row of the raster.
For performance reasons pixels may not always be tightly packed in the memory block returned from mapRasterData so applications should always use this to determine the correct offset between pixels in the image when updating the raster's contents.
unsigned int TSLRasterBuffer::rowStride | ( | ) | const |
Returns the offset in bytes between rows in the image.
For performance reasons rows in the image may not always be tightly packed in the memory block returned from mapRasterData so applications should always use this to determine the starting location of each row in the image.
unsigned char TSLRasterBuffer::transparency | ( | ) | const |
Returns the current transparency level used when drawing the raster.
void TSLRasterBuffer::transparency | ( | unsigned char | value | ) |
Sets the level of transparency to use when drawing the raster. This transparency is applied in addition to any alpha data within the image itself.
The default value is 255.
value | The transparency level of the raster. A value of 0 makes the image fully transparent while 255 makes the image fully opaque. |
void TSLRasterBuffer::unmapRasterData | ( | ) |
Unmaps the memory block returned from mapRasterData, which updates the raster with the new contents if the buffer was mapped with the Write flag. Once this method has been called the pointer returned from mapRasterData is no longer valid and should not be used.
unsigned int TSLRasterBuffer::width | ( | ) | const |
Returns the width of the raster.