BGRABitmap/es

From Lazarus wiki
Revision as of 00:15, 22 March 2010 by Circular (talk | contribs) (screenshots)
Jump to navigationJump to search

About

BGRABitmap is a set of units designed to handle images with transparency (alpha channel). It allows to perform fast memory image processing and pixel manipulations. The standard version should work on any platform. There is an optimised version for Windows. It is not optimised yet for other systems.

The main class is TRGB32Bitmap which is derived from TFPCustomImage. There is also TBGRAPtrBitmap which allows you to modify some data already allocated as a BGRA image. The BGRA format consists of four bytes for each pixel (blue, green, red and alpha in that order).

There are three basic modes for drawing :

  • Drawing with alpha blending (you can draw a transparent object)
  • Replacing pixels including alpha channel (you can draw a hole in the bitmap)
  • Drawing an image except transparent pixels (like a simple sprite)

You can draw using direct drawing functions embedded in the TBGRABitmap class or you can access a Canvas property to draw using standard functions. The second option is slower because it can need some transformations of the picture. To specity the opacity of objects drawn with the Canvas property, you can specify a CanvasOpacity value.

Available direct functions for drawing :

  • pixels, lines, rectangles
  • lines with anti-aliasing
  • round rectangles
  • text with transparency
  • flood fill, replace color
  • loading and saving images
  • resample, merge images

To access directly to pixels, use the Data and Scanline properties. Note that the row order can be reversed according to LineOrder property.

Screenshots

Bgra wirecube.png Bgra chessboard.jpg

License

GNU General Public License

Download and feedback

http://consume.o2switch.net/lazarus/

To do

  • Optimization for other operating systems than Windows

Installation

Add BGRABitmap and BGRABitmap types to the uses clause.