Rx Graph

RX Library

UNIT RxGraph

Overview:
BitmapToMemory
TMappingMethod
GetBitmapPixelFormat
GrayscaleBitmap
SaveBitmapToFile
SetBitmapPixelFormat


Type TMappingMethod
Declaration: TMappingMethod = (mmQuantize, mmTrunc784, mmTrunc666, mmTripel, mmGrayscale);

The TMappingMethod describes possible methods to decrease bitmap color count by using SetBitmapPixelFormat procedure.


Routine BitmapToMemory
Declaration: function BitmapToMemory(Bitmap: TBitmap; Colors: Integer): TStream;

BitMap : pointer to bitmap
Colours: Number of colours. (maximum: 2^32)

This maps a bitmap to a stream to be utilitsed by a memory mapped function or for file streaming purposes.

BitmapToMemory example:
Next code fragment shows how you can decrease the number of colours in a bitmap to 16 colours:

var
__S: TStream;
begin
__S := BitmapToMemory(Picture.Bitmap, 16);
__try
____Picture.Graphic.LoadFromStream(S);
__finally
____S.Free;
__end;
end;


Routine GetBitmapPixelFormat
Declaration: function GetBitmapPixelFormat(ABitmap: TBitmap): TPixelFormat;

The GetBitmapPixelFormat procedure determines in what bit format the bitmap image is displayed.

> GetBitmapPixelFormat example:
if GetBitmapPixelFormat(Image.Bitmap) > pf8bit then
__SetBitmapPixelFormat(Image.Bitmap, pf8bit, mmQuantize);


Routine GrayscaleBitmap
Declaration: procedure GrayscaleBitmap(Bitmap: TBitmap);

This procedure transforms a color bitmap image into grayscale. Each pixel is transformed into the gray pixel (Red = Green = Blue) with the (approximate) same luminosity.

GrayscaleBitmap example:
__GrayscaleBitmap(Image1.Bitmap);


Routine SaveBitmapToFile
Declaration: procedure SaveBitmapToFile(const FileName: string; Bitmap: TBitmap; Colors: Integer);

SaveBitmapToFile example:

var
__Bmp: TBitmap;
begin
__{...}
__Bmp.Assign(Clipboard);
__SaveBitmapToFile(SaveDialog1.FileName, Bmp, 16);
__{...}
end;


Routine SetBitmapPixelFormat
Declaration: procedure SetBitmapPixelFormat(ABitmap: TBitmap; PixelFormat: TPixelFormat; Method: TMappingMethod);

SetBitmapPixelFormat procedure allows you to determine in what bit format the bitmap image specified by ABitmap parameter will be displayed: 8-bit, 24-bit etc. For example, you can use SetBitmapPixelFormat to set the pixel format of the bitmap image to 8-bit for video driveres that cannot display the native format of a bitmap image. You can specify method to decrease bitmap colors count by the Method parameter. Possible values for PixelFormat parameter are: pf1bit, pf4bit, pf8bit, pf24bit.

SetBitmapPixelFormat example:
__SetBitmapPixelFormat(Image.Bitmap, pf8bit, mmQuantize);


Index Page | About | Download
Creation Date: 4 Feb 1998 | Last Update: 16 Mar 2000