Pixmaps provide storage for rectangular regions of pixels.
You can create a new pixmap using the CreatePixmap command, or load a pixmap
using LoadPixmap.
Pixmaps have 5 properties: width, height, a byte pointer to the pixmap's pixels, pitch and
format.
You can retrieve a pointer to a pixmap's pixels using the PixmapPixelPtr command.
A pixmap's pitch refers to the number of bytes between one row of pixels in the pixmap
and the next. To retrieve a pixmap's pitch, use the PixmapPitch command.
A pixmap's pixel format determines how the pixels within a pixmap are stored in memory. This
must be taken into account if you want to access pixels directly via a pixmap's pixel pointer.
You can retrieve the format of a pixmap using the PixmapFormat command, and convert pixmaps
from one format to another using ConvertPixmap.
You can also use ResizePixmap to resize a pixmap and flip a pixmap horizontally or vertically
with XFlipPixmap and YFlipPixmap.
Types
Functions
Function reference
Function CreatePixmap:TPixmap( width,height,format,align_bytes=4 ) |
Returns | A new pixmap object of the specified width and height
|
Description | Create a pixmap |
Information |
format should be one of the following:
Format | Description | PF_A8 | 8 bit alpha | PF_I8 | 8 bit intensity | PF_RGB888 | 24 bit big endian RGB | PF_BGR888 | 24 bit little endian RGB | PF_RGBA8888 | 32 bit big endian RGB with alpha | PF_BGRA8888 | 32 bit little endian RGB with alpha |
Note that the newly created pixmap will contain random data. ClearPixels can
be used to set all pixels to a known value prior to use.
|
Function CreateStaticPixmap:TPixmap( pixels:Byte Ptr,width,height,pitch,format ) |
Returns | A new pixmap object that references an existing block of memory
|
Description | Create a pixmap with existing pixel data |
Information |
The memory referenced by a static pixmap is not released when the pixmap is deleted.
See CreatePixmap for valid pixmap formats.
|
Function CopyPixmap:TPixmap( pixmap:TPixmap ) |
Returns | A new pixmap object
|
Description | Copy a pixmap |
Function ConvertPixmap:TPixmap( pixmap:TPixmap,format ) |
Returns | A new pixmap object with the specified pixel format
|
Description | Convert pixel format of a pixmap |
Information |
See CreatePixmap for valid pixmap formats.
|
Function PixmapWidth( pixmap:TPixmap ) |
Returns | The width, in pixels, of pixmap
|
Description | Get pixmap width |
Function PixmapHeight( pixmap:TPixmap ) |
Returns | The height, in pixels, of pixmap
|
Description | Get pixmap width |
Function PixmapPitch( pixmap:TPixmap ) |
Returns | The pitch, in bytes, of pixmap
|
Description | Get pixmap pitch |
Information |
Pitch refers to the difference, in bytes, between the start of one row of pixels and the start of the next row.
|
Function PixmapFormat( pixmap:TPixmap ) |
Returns | The format of the pixels stored in pixmap
|
Description | Get pixmap format |
Information |
See CreatePixmap for supported formats.
|
Function PixmapPixelPtr:Byte Ptr( pixmap:TPixmap,x=0,y=0 ) |
Returns | A byte pointer to the pixels stored in pixmap
|
Description | Get pixmap pixels |
Function PixmapWindow:TPixmap( pixmap:TPixmap,x,y,width,height ) |
Returns | A new pixmap object
|
Description | Create a pixmap window |
Information | PixmapWindow creates a 'virtual' window into pixmap.
|
Function MaskPixmap:TPixmap( pixmap:TPixmap,mask_red,mask_green,mask_blue ) NoDebug |
Returns | A new pixmap object
|
Description | Mask a pixmap |
Information | MaskPixmap builds a new pixmap with alpha components set to '0' wherever the pixel colors
in the original pixmap match mask_red, mask_green and mask_blue. mask_red, mask_green and mask_blue
should be in the range 0 to 255.
|
Function XFlipPixmap:TPixmap( pixmap:TPixmap ) NoDebug |
Returns | A new pixmap object
|
Description | Flip a pixmap horizontally |
Function YFlipPixmap:TPixmap( pixmap:TPixmap ) NoDebug |
Returns | A new pixmap object
|
Description | Flip a pixmap vertically |
Function ResizePixmap:TPixmap( pixmap:TPixmap,width,height ) NoDebug |
Returns | A new pixmap object of the specified width and height
|
Description | Resize a pixmap |
Function LoadPixmap:TPixmap( url:Object ) |
Returns | A pixmap object
|
Description | Load a pixmap |
Function ReadPixel( pixmap:TPixmap,x,y ) |
Returns | A 32 bit pixel value
|
Description | Read a pixel from a pixmap |
Information |
The returned 32 bit value contains the following components:
bits 24-31 | pixel alpha | bits 16-23 | pixel red | bits 8-15 | pixel green | bits 0-7 | pixel blue |
|
Function WritePixel( pixmap:TPixmap,x,y,argb ) |
Description | Write a pixel to a pixmap |
Information |
The 32 bit argb value contains the following components:
bits 24-31 | pixel alpha | bits 16-23 | pixel red | bits 8-15 | pixel green | bits 0-7 | pixel blue |
|
Function ClearPixels( pixmap:TPixmap,argb=0 ) |
Description | Clear a pixmap |
Information |
Sets all pixels in a pixmap to a 32 bit pixel value.
The 32 bit argb value contains the following components:
bits 24-31 | pixel alpha | bits 16-23 | pixel red | bits 8-15 | pixel green | bits 0-7 | pixel blue |
|