Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxCustomSmartImage.ConvertToBitmap Method

Rasterizes the stored vector image.

#Declaration

Delphi
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: Insert an Image to a Rich Text Document

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;

VCL Shared Libraries: An Inline Image Example in a Rich Text Document

#Limitations

Vector image rasterization is irreversible, since Smart Image containers cannot vectorize bitmaps.

See Also