TdxCustomSmartImage.ImageCodec Property
Specifies the active image format codec.
Declaration
property ImageCodec: TdxSmartImageCodecClass read; write;
Property Value
Type | Description |
---|---|
TdxSmartImageCodecClass | The reference to the active image format codec. Refer to the following section for the full list of image codecs shipped with DevExpress VCL products: Property Values. |
Remarks
Use the ImageCodec
property to identify the current image format or convert the stored image to a different format. All supported formats are implemented as codec classes derived from the TdxSmartImageCodec class. All image format implementations (except for SVG available in DevExpress VCL products rely on the native image format encoder functionality of the Windows Imaging Component (WIC).
Property Values
DevExpress VCL products ship with the following image codec classes registered in the Smart Image codec repository:
Value | Image Format | File Name Extensions[1] | MimeType[2] |
---|---|---|---|
TdxGPImageCodecBMP | Device-Independent Bitmap (BMP/DIB) | '*.bmp;' |
'image/bmp' |
TdxGPImageCodecEMF | Enhanced Windows Metafile (EMF) | '*.emf;' |
'image/emf' |
TdxGPImageCodecGIF | Graphics Interchange Format (GIF) | '*.gif;' |
'image/gif' |
TdxGPImageCodecJPEG | Joint Photographic Experts Group (JPEG) | *.jpeg;*jpg; |
'image/jpg' |
TdxGPImageCodecPNG | Portable Network Graphics (PNG) | '*.png;' |
'image/png' |
TdxGPImageCodecTIFF | Tagged Image File Format (TIFF) | '*.tiff;*.tif;' |
'image/tiff' |
TdxGPImageCodecWMF | Windows Metafile (WMF) | '*wmf' |
'image/wmf' |
TdxSVGImageCodec | Scalable Vector Graphics (SVG) | '*.svg;' |
'image/svg+xml' |
Code Example: Check the Current Image Format
The code example below allows users to select an image in any format and insert the image at the end of a document opened in a TdxRichEditControl. Since inline and floating document images do not support vector images, the code example uses the ImageCodec
property to check if the source image is an SVG.
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;
Smart Image Codec Repository
The TdxSmartImageCodecsRepository class implements a repository that manages references to all TdxSmartImageCodec class descendants and allows DevExpress components to work with images in all supported formats in a uniform manner.
Limitations
You can assign a reference to any supported bitmap codec class to the ImageCodec
to convert a stored bitmap or vector image to a different bitmap format. However, vector image rasterization is irreversible. You cannot assign TdxSVGImageCodec to the ImageCodec
property to vectorize the stored bitmap image.
-
This column lists strings of file name extensions associated with corresponding image formats.
The TdxSmartImageCodec.Extensions class function returns these strings for corresponding TdxSmartImageCodec class descendants listed in the first column.
-
This column lists multi-purpose internet mail extension (MIME) content types associated with corresponding image formats.
The TdxSmartImageCodec.MimeType class function returns these strings for corresponding TdxSmartImageCodec class descendants listed in the first column.