ImageEn, unit iexBitmaps

TIOParams.BitsPerSample

TIOParams.BitsPerSample


Declaration


property BitsPerSample: integer;


Description


Specifies the depth, in bits, for each sample (channel).
Allowed values:
Value Description
1 1 bit black & white
2 to 7 Color mapped bitmap (from 4 to 128 colors)
8 Color mapped (256 colors), 8 bit gray scale, 24 bit RGB, 48 bit CMYK, 24 bit CIELab
16 16 bit gray scale or 48 bit RGB
32 32 bit floating point


Default: 8

Note: Setting BitsPerSample only updates the meta-data. Use a method like ConvertTo to reduce the color palette of the image.


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
- SamplesPerPixel


Example


// 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');