BRL.Pixmap: Functions Types Modinfo Source  

Pixmaps

Pixmaps provide storage for rectangular regions of pixels.

You can create a new pixmap using the CreatePixmap command, or load a pixmap from a stream 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 pixmap's from one format to another using ConvertPixmap.

You can also resize a pixmap, flip a pixmap horizontally or vertically and more.

Functions

Function ConvertPixmap:TPixmap( pixmap:TPixmap,format )
ReturnsA new pixmap object with the specified pixel format.
DescriptionConvert pixel format of a pixmap.
InformationSee CreatePixmap for valid pixmap formats.

Function CopyPixmap:TPixmap( pixmap:TPixmap )
ReturnsA new pixmap object.
DescriptionCopy a pixmap.

Function CreatePixmap:TPixmap( width,height,format,align_bytes=4 )
ReturnsA new pixmap object of the specified width and height.
DescriptionCreate a pixmap.
Informationformat should be one of the following:

FormatDescription
PF_A88 bit alpha
PF_I88 bit intensity
PF_RGB88824 bit big endian RGB
PF_BGR88824 bit little endian RGB
PF_RGBA888832 bit big endian RGB with alpha
PF_BGRA888832 bit little endian RGB with alpha

Function CreateStaticPixmap:TPixmap( pixels:Byte Ptr,width,height,pitch,format )
ReturnsA new pixmap object that references an existing block of memory.
DescriptionCreate a pixmap with existing pixel data.
InformationThe memory referenced by a static pixmap is not released when the pixmap is deleted.

See CreatePixmap for valid pixmap formats.

Function LoadPixmap:TPixmap( url:Object )
ReturnsA pixmap object.
DescriptionLoad a pixmap.

Function MaskPixmap:TPixmap( pixmap:TPixmap,mask_red,mask_green,mask_blue )
ReturnsA new pixmap object.
DescriptionMask a pixmap.
InformationMaskPixmap 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 PixmapFormat( pixmap:TPixmap )
ReturnsThe format of the pixels stored in pixmap.
DescriptionGet pixmap format.
InformationThe returned value will be one of:

FormatDescription
PF_A88 bit alpha
PF_I88 bit intensity
PF_RGB88824 bit big endian RGB
PF_BGR88824 bit little endian RGB
PF_RGBA888832 bit big endian RGB with alpha
PF_BGRA888832 bit big endian RGB with alpha

Function PixmapHeight( pixmap:TPixmap )
ReturnsThe height, in pixels, of pixmap.
DescriptionGet pixmap width.

Function PixmapPitch( pixmap:TPixmap )
ReturnsThe pitch, in bytes, of pixmap.
DescriptionGet pixmap pitch.
InformationPitch refers to the difference, in bytes, between the start of one row of pixels and the start of the next row.

Function PixmapPixelPtr:Byte Ptr( pixmap:TPixmap,x=0,y=0 )
ReturnsA byte pointer to the pixels stored in pixmap.
DescriptionGet pixmap pixels.

Function PixmapWidth( pixmap:TPixmap )
ReturnsThe width, in pixels, of pixmap.
DescriptionGet pixmap width.

Function PixmapWindow:TPixmap( pixmap:TPixmap,x,y,width,height )
ReturnsA new pixmap object.
DescriptionCreate a pixmap window.
InformationPixmapWindow creates a 'virtual' window into pixmap.

Function ReadPixel( pixmap:TPixmap,x,y )
ReturnsA 32 bit pixel value.
DescriptionRead a pixel from a pixmap.
InformationThe returned 32 bit value contains the following components:

bits 24-31pixel alpha
bits 16-23pixel red
bits 8-15pixel green
bits 0-7pixel blue

Function ResizePixmap:TPixmap( pixmap:TPixmap,width,height )
ReturnsA new pixmap object of the specified width and height.
DescriptionResize a pixmap.

Function WritePixel( pixmap:TPixmap,x,y,argb )
DescriptionWrite a pixel to a pixmap.
InformationThe 32 bit argb value contains the following components:

bits 24-31pixel alpha
bits 16-23pixel red
bits 8-15pixel green
bits 0-7pixel blue

Function XFlipPixmap:TPixmap( pixmap:TPixmap )
ReturnsA new pixmap object.
DescriptionFlip a pixmap horizontally.

Function YFlipPixmap:TPixmap( pixmap:TPixmap )
ReturnsA new pixmap object.
DescriptionFlip a pixmap vertically.

Types

Type TPixmap Extends TData
DescriptionThe Pixmap type.
Field capacity
DescriptionThe capacity, in bytes, of the pixmap, or -1 for a static pixmap.
Field format
DescriptionThe pixel format of the pixmap.
Field height
DescriptionThe height, in pixels, of the pixmap.
Field pitch
DescriptionThe pitch, in bytes, of the pixmap.
Field pixels:Byte Ptr
DescriptionA byte pointer to the pixmap's pixels.
Field width
DescriptionThe width, in pixels, of the pixmap.
Method Convert:TPixmap( format )
ReturnsA new TPixmap object in the specified format.
DescriptionConvert a pixmap.
Method Copy:TPixmap()
ReturnsA new TPixmap object.
DescriptionDuplicate a pixmap.
Method Paste( source:TPixmap,x,y )
DescriptionPaste a pixmap.
Method PixelPtr:Byte Ptr( x,y )
ReturnsA byte pointer to the pixel at coordinates x, y.
DescriptionGet memory address of a pixel.
Method ReadPixel( x,y )
ReturnsThe pixel at the specified coordinates packed into an integer.
DescriptionRead a pixel from a pixmap.
Method Window:TPixmap( x,y,width,height )
ReturnsA static pixmap that references the specified rectangle.
DescriptionCreate a virtual window into a pixmap.
Method WritePixel( x,y,argb )
DescriptionWrite a pixel to a pixmap.
Function Create:TPixmap( width,height,format,align=4 )
ReturnsA new TPixmap object.
DescriptionCreate a pixmap.
Function CreateStatic:TPixmap( pixels:Byte Ptr,width,height,pitch,format )
ReturnsA new TPixmap object.
DescriptionCreate a static pixmap.

Type TPixmapLoader
DescriptionAbstract base type for pixmap loaders.
InformationTo create a new pixmap loader, you should extend TPixmapLoader and implement the LoadPixmap method.

To install your pixmap loader, simply create an instance of it using New.
Method LoadPixmap:TPixmap( stream:TStream ) Abstract
DescriptionLoad a pixmap.
InformationThis method must be implemented by extending types.

Module Information

Version1.04
AuthorMark Sibly
LicenseBlitz Shared Source Code
CopyrightBlitz Research Ltd
ModserverBRL
HistoryRemoved AddPixmapLoader function