public void SetColorMask(
int[] colorMask
)
@property (nonatomic, strong, nullable) NSArray<LTRasterColor *> *colorMask
public void setColorMask(int colorMask[])
public:
void SetColorMask(
array<int>^ colorMask
)
def SetColorMask(self,colorMask):
colorMask
An array of 3 integers as follows:
Value | Description |
---|---|
ColorMask[0] |
Red mask |
ColorMask[1] |
Green mask |
ColorMask[2] |
Blue mask. |
The color mask is valid only if Format is set to RasterImageFormat.RawBitfields.
As an example, with 16-bit data arranged as RRR RRGG GGGB BBBB, the masks would be:
ColorMask[0] = 0x7C00
ColorMask[1] = 0x0E30
ColorMask[2] = 0x001F
For 32-bit data, the only valid data is RRRR RRRR GGGG GGGG BBBB BBBB. The masks would be:
ColorMask[0] = 0xFF0000
ColorMask[1] = 0x00FF00
ColorMask[2] = 0x0000FF
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
// This sample loads raw data from a PackBits TIF file
// PackBits.tif is a 24-bit tif packbits compressed file
// PackBits.tif has 46 strips of packbits data
// The strip information is obtained by reading the TIF tags TAG_STRIPOFFSETS and TAG_STRIPBYTECOUNTS
// The strips are directly read and fed to the Compress method
void LoadRawPackbitsStrips(string packTifFile)
{
RasterCodecs codecs = new RasterCodecs();
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Decompress.bmp");
CodecsImageInfo imageInfo = codecs.GetInformation(packTifFile, false);
// StartDecompress
CodecsStartDecompressOptions options = CodecsStartDecompressOptions.Empty;
options.DataType = CodecsStartDecompressDataType.Strips;
options.Format = RasterImageFormat.RawPackBits;
options.Width = imageInfo.Width;
options.Height = imageInfo.Height;
options.BitsPerPixel = imageInfo.BitsPerPixel;
options.LeastSignificantBitFirst = false;
options.Pad4 = false;
options.PlanarConfiguration = CodecsPlanarConfiguration.PlanarFormat;
options.ViewPerspective = imageInfo.ViewPerspective;
options.RawOrder = imageInfo.Order;
options.LoadOrder = CodecsLoadByteOrder.BgrOrGray;
options.XResolution = imageInfo.XResolution;
options.YResolution = imageInfo.YResolution;
options.TiffPhotometricInterpretation = CodecsTiffPhotometricInterpretation.Rgb;
options.SetColorMask(options.GetColorMask());
options.SetPalette(options.GetPalette());
options.UsePalette = false;
object decompressObject = codecs.StartDecompress(options);
// Decompress
const int TAG_STRIPOFFSETS = 0x111;
const int TAG_STRIPBYTECOUNTS = 0x117;
const int TAG_ROWSPERSTRIP = 0x116;
const int MAX_STRIPS = 1000;
int[] stripOffsets = new int[MAX_STRIPS];
int[] stripSizes = new int[MAX_STRIPS];
int[] rowsPerStripBuffer = new int[1];
int maxIndex = ReadTag(codecs, packTifFile, TAG_STRIPOFFSETS, stripOffsets);
ReadTag(codecs, packTifFile, TAG_STRIPBYTECOUNTS, stripSizes);
ReadTag(codecs, packTifFile, TAG_ROWSPERSTRIP, rowsPerStripBuffer);
int rowsPerStrip = rowsPerStripBuffer[0];
FileStream fs = File.OpenRead(packTifFile);
const int row = 0; // Note: this parameter is ignored for strips
const int column = 0; // Column offset of tile
for (int index = 0; index < maxIndex; index++)
{
// seek to the first strip
fs.Seek(stripOffsets[index], SeekOrigin.Begin);
byte[] buffer = new byte[stripSizes[index]];
fs.Read(buffer, 0, buffer.Length);
// Calculate the height of uncompressed strip/tile
int height = rowsPerStrip;
if (index == (maxIndex - 1))
{
// fewer rows per strip
height = imageInfo.Height - (maxIndex - 1) * rowsPerStrip;
}
codecs.Decompress(
decompressObject,
buffer,
0,
buffer.Length,
imageInfo.Width,
height,
row,
column,
CodecsDecompressDataFlags.Complete);
}
fs.Close();
// StopDecompress
RasterImage image = codecs.StopDecompress(decompressObject);
// 'image' contains the uncompressed image
codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);
image.Dispose();
// Clean up
codecs.Dispose();
}
// Returns maximum index
int ReadTag(RasterCodecs codecs, string fileName, int tagId, int[] stripArray)
{
RasterTagMetadata tag = codecs.ReadTag(fileName, 1, tagId);
int[] data = tag.ToInt32();
data.CopyTo(stripArray, 0);
return tag.Count;
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.