TurboDB VCL Component Library TTdbBlobProvider.RegisterBlobFormat Class Method |
Previous Top Next |
Registers an image format.
Delphi syntax:
class procedure RegisterBlobFormat(BitMask, Pattern: Int64; const Tag, Name: string; Format: TTdbBlobFormat; GraphicClass: TGraphicClass);
C++ syntax:
virtual static void __fastcall RegisterBlobFormat(int64 BitMask, int64 Pattern, System::String Tag, System::String Name, TGraphicClass * GraphicClass);
Parameters
BitMask |
64-bit mask to extract pattern bits from the first eight bytes of the blob data |
Pattern |
64-bit pattern to compare with the extracted pattern from the blob data |
Tag |
Short name for the format, e.g. bmp, wav, wmf, gif, png, jpg |
Name |
Long human readable name for the format, e.g. Windows meta file |
Format |
Numeric value identifying the blob format, must be unique within the table |
GraphicClass |
Class object of a TGraphic descendent which is able to ReadData and WriteData the format. |
Description
By default, the blob provider can decode bitmaps, Windows meta files and wave files. Additional image format like gif, png, jpeg etc. can be added by registering the format and a corresponding graphic class. When a blob is loaded, the blob provider ands the first four bytes of the blob with the bit mask and compares the result with the pattern. If it is equal, it creates an instance of the graphic class, passes a stream for the blob to it and calls the ReadData method. The resulting graphic is then handed over to the picture in the Picture property.
The blob provider reads the first eight bytes of the blob data as a 64 bit integer number, therefore the pattern bytes must by given in the opposite order of the physical sequence due to the little endian storage.
Example
This code registers GIF, JPEG and PNG formats with the blob provider.
ImageBlobProvider.RegisterBlobFormat($ffff, $d8ff, 'JPG', 'JPEG Image', tbfJPG, TJpegImage);
ImageBlobProvider.RegisterBlobFormat($ffffffff, $38464947, 'GIF', 'GIF Image', tbfGIF, TGifImage);
ImageBlobProvider.RegisterBlobFormat($ffffffffffffffff, $0a1a0a0d474e5089, 'PNG', 'PNG Image', tbfPNG, TPngImage);
See also