This method converts the image data from a Device Independent Bitmap (DIB) to a Device Dependent Bitmap (DDB)
Parameters
Name | Explanation |
---|---|
ImageHandle | The image handle of the raster image |
Return Value
Returns the Bitmap handle if successful, otherwise returns 0 or null.
Explanation
The BitmapFromDib method converts the image data from a Device Independent Bitmap (DIB) to a Device Dependent Bitmap (DDB). This method only works with raster images and cannot be used with vector images.
When the ImageHandle parameter contains a valid image
handle
The image data that the ImageHandle parameter refers to will be
processed.
When the ImageHandle parameter contains 0
The image data determined by the LayerNo property will be processed. If
the LayerNo property is -1 (the
base image) then the image data referred to by the ImageHandle property will be
processed. If the value of the LayerNo property is between 0 and 99 then
the image data referred to by the Layer(LayerNo).ImageHandle
property will be processed.
Example Code
In C++Builder:
//set raster image in TBitmap
VImageKit1->BarkgroundImageVectorWidth
= 640;
VImageKit1->LayerNo = -1;
if (VImageKit1->ImageHandle == 0)
return;
if (VImageKit1->ImageKind !=
vikRasterImage) return;
Graphics::TBitmap *bm = new
Graphics::TBitmap();
try
{
bm->Handle = VImageKit1->BitmapFromDib();
// Do some
image processing here
}
__finally
{
delete
bm;
}
In Delphi:
{ set raster image in TBitmap }
var
Bitmap1:
TBitmap;
begin
VImageKit1.LayerNo := -1;
if
VImageKit1.ImageHandle = 0 then Exit;
if
VImageKit1.ImageKind <> vikRasterImage then Exit;
Bitmap1 :=
TBitmap.Create;
try
Bitmap1.Handle := VImageKit1.BitmapFromDib;
{Do some image processing here}
finally
Bitmap1.Free;
end;
end;