TdxCustomSmartImage.ConvertToBitmap Method
Rasterizes the stored vector image.
Declaration
procedure ConvertToBitmap;
Remarks
Call the ConvertToBitmap
procedure to rasterize the stored vector image.
A ConvertToBitmap
procedure call has no effect if the Empty property returns True
or the ImageCodec property is set to any other value than TdxSVGImageCodec.
Code Example
The following code example allows users to select an image in any format and insert the image at the end of a document opened in a TdxRichEditControl:
uses
..., dxSVGImage; // This unit contains the TdxSVGImageCodec class declaration
//...
procedure TMyForm.cxButton1Click(Sender: TObject);
var
ADocument: IdxRichEditDocument;
AImageContainer: TdxSmartImage;
AFileName: string;
begin
ADocument := dxRichEditControl1.Document;
dxOpenPictureDialog1.Execute(Handle); // Invokes the "Open" dialog for image file selection
AFileName := dxOpenPictureDialog1.FileName;
if (AFileName = '') then Exit; // Exits the procedure if a user selects no image
AImageContainer := TdxSmartImage.Create; // Creates a Smart Image container
try
AImageContainer.LoadFromFile(AFileName);
if (AImageContainer.ImageCodec = TdxSVGImageCodec) then // If the container stores an SVG image
AImageContainer.ConvertToBitmap; // Rasterizes the vector image
ADocument.Images.Append(AImageContainer); // Creates a new inline image from the stored bitmap
finally
AImageContainer.Free; // Destroys the Smart Image container to prevent memory leaks
end;
end;
Limitations
Vector image rasterization is irreversible, since Smart Image containers cannot vectorize bitmaps.
See Also