C# Class BitMiracle.LibTiff.Classic.TiffRgbaImage

Mostrar archivo Open project: Core-Techs/TiffLibrary Class Usage Examples

Public Methods

Method Description
Create ( Tiff tif, bool stopOnError, string &errorMsg ) : TiffRgbaImage

Creates new instance of the TiffRgbaImage class.

GetRaster ( int raster, int offset, int width, int height ) : bool

Reads the underlaying TIFF image and decodes it into RGBA format raster.

GetRaster reads image into memory using current "get" (Get) method, storing the result in the user supplied RGBA raster using one of the "put" (PutContig or PutSeparate) methods. The raster is assumed to be an array of width times height 32-bit entries, where width must be less than or equal to the width of the image (height may be any non-zero size). If the raster dimensions are smaller than the image, the image data is cropped to the raster bounds. If the raster height is greater than that of the image, then the image data placement depends on the value of ReqOrientation property. Note that the raster is assumed to be organized such that the pixel at location (x, y) is raster[y * width + x]; with the raster origin specified by the value of ReqOrientation property.

Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR, Tiff.GetG, Tiff.GetB, and Tiff.GetA should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).

GetRaster converts non-8-bit images by scaling sample values. Palette, grayscale, bilevel, CMYK, and YCbCr images are converted to RGB transparently. Raster pixels are returned uncorrected by any colorimetry information present in the directory.

Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. SamplesPerPixel minus ExtraSamples).

Palette image colormaps that appear to be incorrectly written as 8-bit values are automatically scaled to 16-bits.

All error messages are directed to the current error handler.

Private Methods

Method Description
CMAP ( int x, int i, int &j ) : void

Palette images with <= 8 bits/sample are handled with a table to avoid lots of shifts and masks. The table is setup so that put*cmaptile (below) can retrieve 8 / bitspersample pixel values simply by indexing into the table with one number.

GREY ( int x, int i, int &j ) : void

Greyscale images with less than 8 bits/sample are handled with a table to avoid lots of shifts and masks. The table is setup so that put*bwtile (below) can retrieve 8 / bitspersample pixel values simply by indexing into the table with one number.

PACK ( int r, int g, int b ) : int
PACK4 ( int r, int g, int b, int a ) : int
PACKW ( short r, short g, short b ) : int
PACKW4 ( short r, short g, short b, short a ) : int
TiffRgbaImage ( ) : System
W2B ( short v ) : int
YCbCrtoRGB ( int &dst, int Y, int Cb, int Cr ) : void

YCbCr -> RGB conversion and packing routines.

buildMap ( ) : bool

Construct any mapping table used by the associated put method.

checkcmap ( ) : int
cvtcmap ( ) : void
gtStripContig ( TiffRgbaImage img, int raster, int offset, int width, int height ) : bool

Get a strip-organized image that has PlanarConfiguration contiguous if SamplesPerPixel > 1 or SamplesPerPixel == 1

gtStripSeparate ( TiffRgbaImage img, int raster, int offset, int width, int height ) : bool

Get a strip-organized image with SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB.

gtTileContig ( TiffRgbaImage img, int raster, int offset, int width, int height ) : bool

Get an tile-organized image that has PlanarConfiguration contiguous if SamplesPerPixel > 1 or SamplesPerPixel == 1

gtTileSeparate ( TiffRgbaImage img, int raster, int offset, int width, int height ) : bool

Get an tile-organized image that has SamplesPerPixel > 1 PlanarConfiguration separated We assume that all such images are RGB.

initCIELabConversion ( ) : PutContigDelegate
initYCbCrConversion ( ) : bool
isCCITTCompression ( ) : bool
makebwmap ( ) : bool
makecmap ( ) : bool
pickContigCase ( ) : bool

Select the appropriate conversion routine for packed data.

pickSeparateCase ( ) : bool

Select the appropriate conversion routine for unpacked data. NB: we assume that unpacked single channel data is directed to the "packed routines.

put16bitbwtile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

16-bit greyscale => colormap/RGB

put1bitbwtile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

1-bit bilevel => colormap/RGB

put1bitcmaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

1-bit palette => colormap/RGB

put2bitbwtile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

2-bit greyscale => colormap/RGB

put2bitcmaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

2-bit palette => colormap/RGB

put4bitbwtile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

4-bit greyscale => colormap/RGB

put4bitcmaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

4-bit palette => colormap/RGB

put8bitcmaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit palette => colormap/RGB

putRGBAAcontig16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

16-bit packed samples => RGBA w/ associated alpha (known to have Map == null)

putRGBAAcontig8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed samples => RGBA w/ associated alpha (known to have Map == null)

putRGBAAseparate16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

16-bit unpacked samples => RGBA w/ associated alpha

putRGBAAseparate8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

8-bit unpacked samples => RGBA w/ associated alpha

putRGBUAcontig16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

16-bit packed samples => RGBA w/ unassociated alpha (known to have Map == null)

putRGBUAcontig8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed samples => RGBA w/ unassociated alpha (known to have Map == null)

putRGBUAseparate16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

16-bit unpacked samples => RGBA w/ unassociated alpha

putRGBUAseparate8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

8-bit unpacked samples => RGBA w/ unassociated alpha

putRGBcontig16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

16-bit packed samples => RGB

putRGBcontig8bitCMYKMaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed CMYK samples w/Map => RGB NB: The conversion of CMYK->RGB is *very* crude.

putRGBcontig8bitCMYKtile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed CMYK samples w/o Map => RGB. NB: The conversion of CMYK->RGB is *very* crude.

putRGBcontig8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed samples, no Map => RGB

putRGBseparate16bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

16-bit unpacked samples => RGB

putRGBseparate8bittile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

8-bit unpacked samples => RGB

putcontig8bitCIELab ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed CIE L*a*b 1976 samples => RGB

putcontig8bitYCbCr11tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ no subsampling => RGB

putcontig8bitYCbCr12tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 1,2 subsampling => RGB

putcontig8bitYCbCr21tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 2,1 subsampling => RGB

putcontig8bitYCbCr22tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 2,2 subsampling => RGB

putcontig8bitYCbCr41tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 4,1 subsampling => RGB

putcontig8bitYCbCr42tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 4,2 subsampling => RGB

putcontig8bitYCbCr44tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit packed YCbCr samples w/ 4,4 subsampling => RGB

putgreytile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void

8-bit greyscale => colormap/RGB

putseparate8bitYCbCr11tile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset1, int offset2, int offset3, int offset4, int bufferShift ) : void

8-bit packed YCbCr samples w/ no subsampling => RGB

setorientation ( ) : int
setupMap ( ) : bool

Construct a mapping table to convert from the range of the data samples to [0, 255] - for display. This process also handles inverting B&W images when needed.

Method Details

Create() public static method

Creates new instance of the TiffRgbaImage class.
public static Create ( Tiff tif, bool stopOnError, string &errorMsg ) : TiffRgbaImage
tif Tiff /// The instance of the class used to retrieve /// image data. ///
stopOnError bool /// if set to true then an error will terminate the conversion; otherwise "get" /// methods will continue processing data until all the possible data in the image have /// been requested. ///
errorMsg string The error message (if any) gets placed here.
return TiffRgbaImage

GetRaster() public method

Reads the underlaying TIFF image and decodes it into RGBA format raster.

GetRaster reads image into memory using current "get" (Get) method, storing the result in the user supplied RGBA raster using one of the "put" (PutContig or PutSeparate) methods. The raster is assumed to be an array of width times height 32-bit entries, where width must be less than or equal to the width of the image (height may be any non-zero size). If the raster dimensions are smaller than the image, the image data is cropped to the raster bounds. If the raster height is greater than that of the image, then the image data placement depends on the value of ReqOrientation property. Note that the raster is assumed to be organized such that the pixel at location (x, y) is raster[y * width + x]; with the raster origin specified by the value of ReqOrientation property.

Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR, Tiff.GetG, Tiff.GetB, and Tiff.GetA should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).

GetRaster converts non-8-bit images by scaling sample values. Palette, grayscale, bilevel, CMYK, and YCbCr images are converted to RGB transparently. Raster pixels are returned uncorrected by any colorimetry information present in the directory.

Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. SamplesPerPixel minus ExtraSamples).

Palette image colormaps that appear to be incorrectly written as 8-bit values are automatically scaled to 16-bits.

All error messages are directed to the current error handler.

public GetRaster ( int raster, int offset, int width, int height ) : bool
raster int The raster (the buffer to place decoded image data to).
offset int The zero-based byte offset in at which /// to begin storing decoded bytes.
width int The raster width.
height int The raster height.
return bool