TIOParams.SamplesPerPixel
Declaration
property SamplesPerPixel: integer;
Description
Specifies the Samples (channels) for each pixel.
Allowed values:
Parameter | Description |
1 | Single channel, color-mapped or gray scale image |
3 | Three channels, RGB or CIELab |
4 | Four channels, CMYK or BGRA |
Default: 3
Note:
◼Setting SamplesPerPixel only updates the meta-data. Use a method like
ConvertTo to reduce the color palette of the image.
◼If
AutoSetBitDepth is enabled, then setting
PixelFormat will automatically update SamplesPerPixel and
BitsPerSample◼If you are using a
TIEMultiBitmap or
TImageEnMView, you can use
DuplicateCompressionInfo to propogate the parameter to all frames
BitsPerSample and SamplesPerPixel
SamplesPerPixel specifies the number of channels within an image, for example a gray-scale image has 1 channel, whereas a full color (RGB) image typically has three three channels, or four for some formats containing alpha transparency.
BitsPerSample specifies the amount of depth within each sample. A gray-scale with 256 levels of gray has SamplesPerPixel=1 and BitsPerSample=8 (2^8 = 256), whereas a monochrome image has SamplesPerPixel=1 and BitsPerSample=1. A full color JPEG has SamplesPerPixel=3 and BitsPerSample=8. Indexed/mapped color formats, such as GIF, will have one channel (SamplesPerPixel=1).
Bits per Pixel =
SamplesPerPixel *
BitsPerSample.
See Also
◼ConvertTo◼BitsPerSample◼PixelFormat◼JPEG_ColorSpace◼J2000_ColorSpace◼TIFF_PhotometInterpret◼TIFF_JPEGColorSpace◼AutoSetBitDepth// Save 256 color mapped bitmap
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.SaveToFile('D:\Alfa.bmp');
// Load a full-color image and save it as 256 color one
ImageEnView1.IO.LoadFromFile('D:\Im.jpg');
ImageEnView1.Proc.ConvertTo(ie8p, ieptFixedHalftone256, iedtOrdered8x8);
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.SaveToFile('D:\Image256.bmp');
// 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');
// Save a monochrome TIFF image
ImageEnView1.IO.Params.BitsPerSample := 1;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.Params.TIFF_Compression := ioTIFF_G4FAX;
ImageEnView1.IO.SaveToFile('D:\output.tif');