ImageEn, unit iexBitmaps

TIEBitmap.PixelFormat

TIEBitmap.PixelFormat

Declaration

property PixelFormat: TIEPixelFormat;

Description

Specifies the image pixel format.
You can set PixelFormat to convert an image from one format to another.

Note:
Ensure that AutoSetBitDepth is enabled, so setting PixelFormat will automatically update SamplesPerPixel and BitsPerSample
For full color images use ie24RGB (which is equivalent to 32bit if the AlphaChannel is enabled)
You cannot set PixelFormat to the following if the bitmap location is ieTBitmap: ie32f, ieCMYK, ieCIELab, ie48RGB
The alpha channel is maintained when converting

Examples

Also see: Automated Samples
// Set pixel format to 8bit gray-scale
IEGlobalSettings().AutoSetBitDepth := True;
ImageEnView1.IEBitmap.PixelFormat := ie8g;
ImageEnView1.Update();


// Save 32bit gray-scale TIFF (ie32f)
// Note: Compression must be: ioTIFF_UNCOMPRESSED, ioTIFF_LZW, ioTIFF_PACKBITS or ioTIFF_ZIP
ImageEnView1.LegacyBitmap := false;
ImageEnView1.IEBitmap.PixelFormat := ie32f;
ImageEnView1.IO.Params.BitsPerSample := 32;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.Params.TIFF_PhotometInterpret := ioTIFF_BLACKISZERO;
ImageEnView1.IO.Params.TIFF_Compression := ioTIFF_UNCOMPRESSED;
ImageEnView1.IO.SaveToFileTIFF('D:\GrayTiff32.tiff');


// Convert a 32bit PNG file to an 8bit PNG (without transparency)
ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png');

// Remove alpha channel and make background white
ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clWhite );

// Set PixelFormat to 8bit
ImageEnView1.IEBitmap.PixelFormat := ie8p;

// Use PixelFormat as authoritative source of bit-depth
IEGlobalSettings().AutoSetBitDepth := True;

ImageEnView1.IO.SaveToFile('D:\No-Alpha.png');


// Convert image in TImageEnView to 48 bit image
ImageEnView1.IEBitmap.Location := ieFile; // Location must not be ieTBitmap for some native pixel formats
ImageEnView1.IEBitmap.PixelFormat := ie48RGB;

See Also

ConvertTo
SamplesPerPixel
BitsPerSample
JPEG_ColorSpace
J2000_ColorSpace
TIFF_PhotometInterpret
TIFF_JPEGColorSpace
AutoSetBitDepth