Tiff¶
Namespace: ThinkGeo.Core.LibTiff
Tag Image File Format (TIFF)
public class Tiff : System.IDisposable
Inheritance Object → Tiff
Implements IDisposable
Remarks:
Based on Rev 6.0 from
Properties¶
AssemblyVersion¶
Gets the version of the library's assembly.
public static string AssemblyVersion { get; }
Property Value¶
String
The version of the library's assembly.
Methods¶
ReadRGBAImage(Int32, Int32, Int32[])¶
Reads the image and decodes it into RGBA format raster.
public bool ReadRGBAImage(int width, int height, Int32[] raster)
Parameters¶
width
Int32
The raster width.
height
Int32
The raster height.
raster
Int32[]
The raster (the buffer to place decoded image data to).
Returns¶
Boolean
true if the image was successfully read and converted; otherwise, false is returned if an error was encountered.
Remarks:
ReadRGBAImage reads a strip- or tileView-based image into memory, storing the result in the user supplied RGBA . The raster is assumed to be an array of times 32-bit entries, where must be less than or equal to the width of the image ( 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 are placed in the lower part of the raster. Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin in the lower-left hand corner. Please use if you want to specify another raster origin.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
ReadRGBAImage 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.
ReadRGBAImage is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
ReadRGBAImage(Int32, Int32, Int32[], Boolean)¶
Reads the image and decodes it into RGBA format raster.
public bool ReadRGBAImage(int width, int height, Int32[] raster, bool stopOnError)
Parameters¶
width
Int32
The raster width.
height
Int32
The raster height.
raster
Int32[]
The raster (the buffer to place decoded image data to).
stopOnError
Boolean
if set to true then an error will terminate the operation; otherwise method will continue processing data until all the possible data in the image have been requested.
Returns¶
Boolean
true if the image was successfully read and converted; otherwise, false is returned if an error was encountered and stopOnError is false.
Remarks:
ReadRGBAImage reads a strip- or tileView-based image into memory, storing the result in the user supplied RGBA . The raster is assumed to be an array of times 32-bit entries, where must be less than or equal to the width of the image ( 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 are placed in the lower part of the raster. Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin in the lower-left hand corner. Please use if you want to specify another raster origin.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
ReadRGBAImage 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.
ReadRGBAImage is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
ReadRGBAImageOriented(Int32, Int32, Int32[], Orientation)¶
Reads the image and decodes it into RGBA format raster using specified raster origin.
public bool ReadRGBAImageOriented(int width, int height, Int32[] raster, Orientation orientation)
Parameters¶
width
Int32
The raster width.
height
Int32
The raster height.
raster
Int32[]
The raster (the buffer to place decoded image data to).
orientation
Orientation
The raster origin position.
Returns¶
Boolean
true if the image was successfully read and converted; otherwise, false is returned if an error was encountered.
Remarks:
ReadRGBAImageOriented reads a strip- or tileView-based image into memory, storing the result in the user supplied RGBA . The raster is assumed to be an array of times 32-bit entries, where must be less than or equal to the width of the image ( 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 . Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin specified by parameter.
When ReadRGBAImageOriented is used with Orientation.BOTLEFT for the the produced result is the same as retuned by .
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
ReadRGBAImageOriented 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.
ReadRGBAImageOriented is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
ReadRGBAImageOriented(Int32, Int32, Int32[], Orientation, Boolean)¶
Reads the image and decodes it into RGBA format raster using specified raster origin.
public bool ReadRGBAImageOriented(int width, int height, Int32[] raster, Orientation orientation, bool stopOnError)
Parameters¶
width
Int32
The raster width.
height
Int32
The raster height.
raster
Int32[]
The raster (the buffer to place decoded image data to).
orientation
Orientation
The raster origin position.
stopOnError
Boolean
if set to true then an error will terminate the operation; otherwise method will continue processing data until all the possible data in the image have been requested.
Returns¶
Boolean
true if the image was successfully read and converted; otherwise, false is returned if an error was encountered and stopOnError is false.
Remarks:
ReadRGBAImageOriented reads a strip- or tileView-based image into memory, storing the result in the user supplied RGBA . The raster is assumed to be an array of times 32-bit entries, where must be less than or equal to the width of the image ( 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 . Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin specified by parameter.
When ReadRGBAImageOriented is used with Orientation.BOTLEFT for the the produced result is the same as retuned by .
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
ReadRGBAImageOriented 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.
ReadRGBAImageOriented is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
ReadRGBAStrip(Int32, Int32[])¶
Reads a whole strip of a strip-based image, decodes it and converts it to RGBA format.
public bool ReadRGBAStrip(int row, Int32[] raster)
Parameters¶
row
Int32
The row.
raster
Int32[]
The RGBA raster.
Returns¶
Boolean
true if the strip was successfully read and converted; otherwise, false
Remarks:
ReadRGBAStrip reads a single strip of a strip-based image into memory, storing the result in the user supplied RGBA . If specified strip is the last strip, then it will only contain the portion of the strip that is actually within the image space. The raster is assumed to be an array of width times rowsperstrip 32-bit entries, where width is the width of the image (TiffTag.IMAGEWIDTH) and rowsperstrip is the maximum lines in a strip (TiffTag.ROWSPERSTRIP).
The value should be the row of the first row in the strip (strip * rowsperstrip, zero based).
Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin in the lower-left hand corner of the strip. That is bottom to top organization. When reading a partial last strip in the file the last line of the image will begin at the beginning of the buffer.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
See TiffRgbaImage for more details on how various image types are converted to RGBA values.
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.
ReadRGBAStrip's main advantage over the similar function is that for large images a single buffer capable of holding the whole image doesn't need to be allocated, only enough for one strip. The Tiff.ReadRGBATile(Int32, Int32, Int32[]) function does a similar operation for tiled images.
ReadRGBAStrip is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
ReadRGBATile(Int32, Int32, Int32[])¶
Reads a whole tileView of a tileView-based image, decodes it and converts it to RGBA format.
public bool ReadRGBATile(int col, int row, Int32[] raster)
Parameters¶
col
Int32
The column.
row
Int32
The row.
raster
Int32[]
The RGBA raster.
Returns¶
Boolean
true if the strip was successfully read and converted; otherwise, false
Remarks:
ReadRGBATile reads a single tileView of a tileView-based image into memory, storing the result in the user supplied RGBA . The raster is assumed to be an array of width times length 32-bit entries, where width is the width of the tileView (TiffTag.TILEWIDTH) and length is the height of a tileView (TiffTag.TILELENGTH).
The and values are the offsets from the top left corner of the image to the top left corner of the tileView to be read. They must be an exact multiple of the tileView width and length.
Note that the raster is assumed to be organized such that the pixel at location (x, y) is [y * width + x]; with the raster origin in the lower-left hand corner of the tileView. That is bottom to top organization. Edge tiles which partly fall off the image will be filled out with appropriate zeroed areas.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The Tiff.GetR(Int32), Tiff.GetG(Int32), Tiff.GetBitRevTable(Boolean), and Tiff.GetA(Int32) should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255).
See TiffRgbaImage for more details on how various image types are converted to RGBA values.
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.
ReadRGBATile's main advantage over the similar function is that for large images a single buffer capable of holding the whole image doesn't need to be allocated, only enough for one tileView. The Tiff.ReadRGBAStrip(Int32, Int32[]) function does a similar operation for stripped images.
ReadRGBATile is just a wrapper around the more general TiffRgbaImage facilities.
All error messages are directed to the current error handler.
RGBAImageOK(String&)¶
Check the image to see if it can be converted to RGBA format.
public bool RGBAImageOK(String& errorMsg)
Parameters¶
errorMsg
String&
The error message (if any) gets placed here.
Returns¶
Boolean
true if the image can be converted to RGBA format; otherwise, false is returned and contains the reason why it is being rejected.
Remarks:
To convert the image to RGBA format please use , , Tiff.ReadRGBAStrip(Int32, Int32[]) or Tiff.ReadRGBATile(Int32, Int32, Int32[])
Convertible images should follow this rules: 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).
FileName()¶
Gets the name of the file or ID string for this Tiff.
public string FileName()
Returns¶
String
The name of the file or ID string for this .
Remarks:
If this Tiff was created using Tiff.Open(String, String) method then value of fileName parameter of Tiff.Open(String, String) method is returned. If this Tiff was created using Tiff.ClientOpen(String, String, Object, TiffStream) then value of name parameter of Tiff.ClientOpen(String, String, Object, TiffStream) method is returned.
SetFileName(String)¶
Sets the new ID string for this Tiff.
public string SetFileName(string name)
Parameters¶
name
String
The ID string for this .
Returns¶
String
The previous file name or ID string for this .
Remarks:
Please note, that is an arbitrary string used as ID for this Tiff. It's not required to be a file name or anything meaningful at all.
Error(Tiff, String, String, Object[])¶
Invokes the library-wide error handling methods to (normally) write an error message to the Console.Error.
public static void Error(Tiff tif, string method, string format, Object[] args)
Parameters¶
tif
Tiff
An instance of the class. Can be null.
method
String
The method where an error is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which an error is detected.
Applications that desire to capture control in the event of an error should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
Error(String, String, Object[])¶
Invokes the library-wide error handling methods to (normally) write an error message to the Console.Error.
public static void Error(string method, string format, Object[] args)
Parameters¶
method
String
The method where an error is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which an error is detected.
Applications that desire to capture control in the event of an error should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
ErrorExt(Tiff, Object, String, String, Object[])¶
Invokes the library-wide error handling methods to (normally) write an error message to the Console.Error.
public static void ErrorExt(Tiff tif, object clientData, string method, string format, Object[] args)
Parameters¶
tif
Tiff
An instance of the class. Can be null.
clientData
Object
The client data to be passed to error handler.
method
String
The method where an error is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which an error is detected.
The parameter can be anything you want. It will be passed unchanged to the error handler. Default error handler does not use it. Only custom error handlers may make use of it.
Applications that desire to capture control in the event of an error should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
ErrorExt(Object, String, String, Object[])¶
Invokes the library-wide error handling methods to (normally) write an error message to the Console.Error.
public static void ErrorExt(object clientData, string method, string format, Object[] args)
Parameters¶
clientData
Object
The client data to be passed to error handler.
method
String
The method where an error is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which an error is detected.
The parameter can be anything you want. It will be passed unchanged to the error handler. Default error handler does not use it. Only custom error handlers may make use of it.
Applications that desire to capture control in the event of an error should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
Warning(Tiff, String, String, Object[])¶
Invokes the library-wide warning handling methods to (normally) write a warning message to the Console.Error.
public static void Warning(Tiff tif, string method, string format, Object[] args)
Parameters¶
tif
Tiff
An instance of the class. Can be null.
method
String
The method in which a warning is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which a warning is detected.
Applications that desire to capture control in the event of a warning should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
Warning(String, String, Object[])¶
Invokes the library-wide warning handling methods to (normally) write a warning message to the Console.Error.
public static void Warning(string method, string format, Object[] args)
Parameters¶
method
String
The method in which a warning is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which a warning is detected.
Applications that desire to capture control in the event of a warning should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
WarningExt(Tiff, Object, String, String, Object[])¶
Invokes the library-wide warning handling methods to (normally) write a warning message to the Console.Error and passes client data to the warning handler.
public static void WarningExt(Tiff tif, object clientData, string method, string format, Object[] args)
Parameters¶
tif
Tiff
An instance of the class. Can be null.
clientData
Object
The client data to be passed to warning handler.
method
String
The method in which a warning is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which a warning is detected.
The parameter can be anything you want. It will be passed unchanged to the warning handler. Default warning handler does not use it. Only custom warning handlers may make use of it.
Applications that desire to capture control in the event of a warning should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
WarningExt(Object, String, String, Object[])¶
Invokes the library-wide warning handling methods to (normally) write a warning message to the Console.Error and passes client data to the warning handler.
public static void WarningExt(object clientData, string method, string format, Object[] args)
Parameters¶
clientData
Object
The client data to be passed to warning handler.
method
String
The method in which a warning is detected.
format
String
A composite format string (see Remarks).
args
Object[]
An object array that contains zero or more objects to format.
Remarks:
The is a composite format string that uses the same format as method. The parameter, if not null
, is printed before the message; it typically is used to identify the method in which a warning is detected.
The parameter can be anything you want. It will be passed unchanged to the warning handler. Default warning handler does not use it. Only custom warning handlers may make use of it.
Applications that desire to capture control in the event of a warning should use Tiff.SetErrorHandler(TiffErrorHandler) to override the default error and warning handler.
SetErrorHandler(TiffErrorHandler)¶
Sets an instance of the TiffErrorHandler class as custom library-wide error and warning handler.
public static TiffErrorHandler SetErrorHandler(TiffErrorHandler errorHandler)
Parameters¶
errorHandler
TiffErrorHandler
An instance of the class to set as custom library-wide error and warning handler.
Returns¶
Previous error handler or null if there was no error handler set.
SetTagExtender(TiffExtendProc)¶
Sets the tag extender method.
public static TiffExtendProc SetTagExtender(TiffExtendProc extender)
Parameters¶
extender
TiffExtendProc
The tag extender method.
Returns¶
TiffExtendProc
Previous tag extender method.
Remarks:
Extender method is called upon creation of each instance of Tiff object.
ReadTile(Byte[], Int32, Int32, Int32, Int32, Int16)¶
Reads and decodes a tileView of data from an open TIFF file/stream.
public int ReadTile(Byte[] buffer, int offset, int x, int y, int z, short plane)
Parameters¶
buffer
Byte[]
The buffer to place read and decoded image data to.
offset
Int32
The zero-based byte offset in at which to begin storing read and decoded bytes.
x
Int32
The x-coordinate of the pixel within a tileView to be read and decoded.
y
Int32
The y-coordinate of the pixel within a tileView to be read and decoded.
z
Int32
The z-coordinate of the pixel within a tileView to be read and decoded.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Int32
The number of bytes in the decoded tileView or -1 if an error occurred.
Remarks:
The tileView to read and decode is selected by the (x, y, z, plane) coordinates (i.e. ReadTile returns the data for the tileView containing the specified coordinates. The data placed in are returned decompressed and, typically, in the native byte- and bit-ordering, but are otherwise packed (see further below). The buffer must be large enough to hold an entire tileView of data. Applications should call the to find out the size (in bytes) of a tileView buffer. The and parameters are always used by ReadTile. The parameter is used if the image is deeper than 1 slice (a value of TiffTag.IMAGEDEPTH > 1). In other cases the value of is ignored. The parameter is used only if data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). In other cases the value of is ignored.
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the value of TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
ReadEncodedTile(Int32, Byte[], Int32, Int32)¶
Reads a tileView of data from an open TIFF file/stream, decompresses it and places specified amount of decompressed bytes into the user supplied buffer.
public int ReadEncodedTile(int tile, Byte[] buffer, int offset, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to read.
buffer
Byte[]
The buffer to place decompressed tileView bytes to.
offset
Int32
The zero-based byte offset in buffer at which to begin storing decompressed tileView bytes.
count
Int32
The maximum number of decompressed tileView bytes to be stored to buffer.
Returns¶
Int32
The actual number of bytes of data that were placed in buffer or -1 if an error was encountered.
Remarks:
The value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
To read a full tileView of data the data buffer should typically be at least as large as the number returned by . If the -1 passed in parameter, the whole tileView will be read. You should be sure you have enough space allocated for the buffer.
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
ReadRawTile(Int32, Byte[], Int32, Int32)¶
Reads the undecoded contents of a tileView of data from an open TIFF file/stream and places specified amount of read bytes into the user supplied buffer.
public int ReadRawTile(int tile, Byte[] buffer, int offset, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to read.
buffer
Byte[]
The buffer to place read tileView bytes to.
offset
Int32
The zero-based byte offset in buffer at which to begin storing read tileView bytes.
count
Int32
The maximum number of read tileView bytes to be stored to buffer.
Returns¶
Int32
The actual number of bytes of data that were placed in buffer or -1 if an error was encountered.
Remarks:
The value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
To read a full tileView of data the data buffer should typically be at least as large as the number returned by Tiff.RawTileSize(Int32). If the -1 passed in parameter, the whole tileView will be read. You should be sure you have enough space allocated for the buffer.
WriteTile(Byte[], Int32, Int32, Int32, Int16)¶
Encodes and writes a tileView of data to an open TIFF file/stream.
public int WriteTile(Byte[] buffer, int x, int y, int z, short plane)
Parameters¶
buffer
Byte[]
The buffer with image data to be encoded and written.
x
Int32
The x-coordinate of the pixel within a tileView to be encoded and written.
y
Int32
The y-coordinate of the pixel within a tileView to be encoded and written.
z
Int32
The z-coordinate of the pixel within a tileView to be encoded and written.
plane
Int16
The zero-based index of the sample plane.
Returns¶
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
The tileView to place encoded data is selected by the (x, y, z, plane) coordinates (i.e. WriteTile writes data to the tileView containing the specified coordinates. WriteTile (potentially) encodes the data and writes it to open file/stream. The buffer must contain an entire tileView of data. Applications should call the to find out the size (in bytes) of a tileView buffer. The and parameters are always used by WriteTile. The parameter is used if the image is deeper than 1 slice (a value of TiffTag.IMAGEDEPTH > 1). In other cases the value of is ignored. The parameter is used only if data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). In other cases the value of is ignored.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteTile does not support automatically growing the image on each write (as does).
WriteTile(Byte[], Int32, Int32, Int32, Int32, Int16)¶
Encodes and writes a tileView of data to an open TIFF file/stream.
public int WriteTile(Byte[] buffer, int offset, int x, int y, int z, short plane)
Parameters¶
buffer
Byte[]
The buffer with image data to be encoded and written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes to be encoded and written.
x
Int32
The x-coordinate of the pixel within a tileView to be encoded and written.
y
Int32
The y-coordinate of the pixel within a tileView to be encoded and written.
z
Int32
The z-coordinate of the pixel within a tileView to be encoded and written.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Int32
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
The tileView to place encoded data is selected by the (x, y, z, plane) coordinates (i.e. WriteTile writes data to the tileView containing the specified coordinates. WriteTile (potentially) encodes the data and writes it to open file/stream. The buffer must contain an entire tileView of data. Applications should call the to find out the size (in bytes) of a tileView buffer. The and parameters are always used by WriteTile. The parameter is used if the image is deeper than 1 slice (a value of TiffTag.IMAGEDEPTH > 1). In other cases the value of is ignored. The parameter is used only if data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). In other cases the value of is ignored.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteTile does not support automatically growing the image on each write (as does).
ReadEncodedStrip(Int32, Byte[], Int32, Int32)¶
Reads a strip of data from an open TIFF file/stream, decompresses it and places specified amount of decompressed bytes into the user supplied buffer.
public int ReadEncodedStrip(int strip, Byte[] buffer, int offset, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to read.
buffer
Byte[]
The buffer to place decompressed strip bytes to.
offset
Int32
The zero-based byte offset in buffer at which to begin storing decompressed strip bytes.
count
Int32
The maximum number of decompressed strip bytes to be stored to buffer.
Returns¶
Int32
The actual number of bytes of data that were placed in buffer or -1 if an error was encountered.
Remarks:
The value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
To read a full strip of data the data buffer should typically be at least as large as the number returned by . If the -1 passed in parameter, the whole strip will be read. You should be sure you have enough space allocated for the buffer.
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
ReadRawStrip(Int32, Byte[], Int32, Int32)¶
Reads the undecoded contents of a strip of data from an open TIFF file/stream and places specified amount of read bytes into the user supplied buffer.
public int ReadRawStrip(int strip, Byte[] buffer, int offset, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to read.
buffer
Byte[]
The buffer to place read bytes to.
offset
Int32
The zero-based byte offset in buffer at which to begin storing read bytes.
count
Int32
The maximum number of read bytes to be stored to buffer.
Returns¶
Int32
The actual number of bytes of data that were placed in buffer or -1 if an error was encountered.
Remarks:
The value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
To read a full strip of data the data buffer should typically be at least as large as the number returned by Tiff.RawStripSize(Int32). If the -1 passed in parameter, the whole strip will be read. You should be sure you have enough space allocated for the buffer.
WriteEncodedStrip(Int32, Byte[], Int32)¶
Encodes and writes a strip of data to an open TIFF file/stream.
public int WriteEncodedStrip(int strip, Byte[] buffer, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to write.
buffer
Byte[]
The buffer with image data to be encoded and written.
count
Int32
The maximum number of strip bytes to be read from .
Returns¶
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
WriteEncodedStrip encodes bytes of raw data from and append the result to the specified strip; replacing any previously written data. Note that the value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
If there is no space for the strip, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the strip (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8.
WriteEncodedStrip(Int32, Byte[], Int32, Int32)¶
Encodes and writes a strip of data to an open TIFF file/stream.
public int WriteEncodedStrip(int strip, Byte[] buffer, int offset, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to write.
buffer
Byte[]
The buffer with image data to be encoded and written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes to be encoded and written.
count
Int32
The maximum number of strip bytes to be read from .
Returns¶
Int32
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
WriteEncodedStrip encodes bytes of raw data from and append the result to the specified strip; replacing any previously written data. Note that the value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
If there is no space for the strip, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the strip (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8.
WriteRawStrip(Int32, Byte[], Int32)¶
Writes a strip of raw data to an open TIFF file/stream.
public int WriteRawStrip(int strip, Byte[] buffer, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to write.
buffer
Byte[]
The buffer with raw image data to be written.
count
Int32
The maximum number of strip bytes to be read from .
Returns¶
The number of written bytes or -1 if an error occurred.
Remarks:
WriteRawStrip appends bytes of raw data from to the specified strip; replacing any previously written data. Note that the value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
If there is no space for the strip, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the strip (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
WriteRawStrip(Int32, Byte[], Int32, Int32)¶
Writes a strip of raw data to an open TIFF file/stream.
public int WriteRawStrip(int strip, Byte[] buffer, int offset, int count)
Parameters¶
strip
Int32
The zero-based index of the strip to write.
buffer
Byte[]
The buffer with raw image data to be written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes to be written.
count
Int32
The maximum number of strip bytes to be read from .
Returns¶
Int32
The number of written bytes or -1 if an error occurred.
Remarks:
WriteRawStrip appends bytes of raw data from to the specified strip; replacing any previously written data. Note that the value of is a "raw strip number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeStrip(Int32, Int16) automatically does this when converting an (row, plane) to a strip index.
If there is no space for the strip, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the strip (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
WriteEncodedTile(Int32, Byte[], Int32)¶
Encodes and writes a tileView of data to an open TIFF file/stream.
public int WriteEncodedTile(int tile, Byte[] buffer, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to write.
buffer
Byte[]
The buffer with image data to be encoded and written.
count
Int32
The maximum number of tileView bytes to be read from .
Returns¶
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
WriteEncodedTile encodes bytes of raw data from and append the result to the end of the specified tileView. Note that the value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
There must be space for the data. The function clamps individual writes to a tileView to the tileView size, but does not (and can not) check that multiple writes to the same tileView were performed.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteEncodedTile does not support automatically growing the image on each write (as does).
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8.
WriteEncodedTile(Int32, Byte[], Int32, Int32)¶
Encodes and writes a tileView of data to an open TIFF file/stream.
public int WriteEncodedTile(int tile, Byte[] buffer, int offset, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to write.
buffer
Byte[]
The buffer with image data to be encoded and written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes to be encoded and written.
count
Int32
The maximum number of tileView bytes to be read from .
Returns¶
Int32
The number of encoded and written bytes or -1 if an error occurred.
Remarks:
WriteEncodedTile encodes bytes of raw data from and append the result to the end of the specified tileView. Note that the value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
There must be space for the data. The function clamps individual writes to a tileView to the tileView size, but does not (and can not) check that multiple writes to the same tileView were performed.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteEncodedTile does not support automatically growing the image on each write (as does).
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8.
WriteRawTile(Int32, Byte[], Int32)¶
Writes a tileView of raw data to an open TIFF file/stream.
public int WriteRawTile(int tile, Byte[] buffer, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to write.
buffer
Byte[]
The buffer with raw image data to be written.
count
Int32
The maximum number of tileView bytes to be read from .
Returns¶
The number of written bytes or -1 if an error occurred.
Remarks:
WriteRawTile appends bytes of raw data to the end of the specified tileView. Note that the value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
There must be space for the data. The function clamps individual writes to a tileView to the tileView size, but does not (and can not) check that multiple writes to the same tileView were performed.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteRawTile does not support automatically growing the image on each write (as does).
WriteRawTile(Int32, Byte[], Int32, Int32)¶
Writes a tileView of raw data to an open TIFF file/stream.
public int WriteRawTile(int tile, Byte[] buffer, int offset, int count)
Parameters¶
tile
Int32
The zero-based index of the tileView to write.
buffer
Byte[]
The buffer with raw image data to be written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes to be written.
count
Int32
The maximum number of tileView bytes to be read from .
Returns¶
Int32
The number of written bytes or -1 if an error occurred.
Remarks:
WriteRawTile appends bytes of raw data to the end of the specified tileView. Note that the value of is a "raw tileView number". That is, the caller must take into account whether or not the data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE). Tiff.ComputeTile(Int32, Int32, Int32, Int16) automatically does this when converting an (x, y, z, plane) coordinate quadruple to a tileView number.
There must be space for the data. The function clamps individual writes to a tileView to the tileView size, but does not (and can not) check that multiple writes to the same tileView were performed.
A correct value for the TiffTag.IMAGELENGTH tag must be setup before writing; WriteRawTile does not support automatically growing the image on each write (as does).
SetWriteOffset(Int64)¶
Sets the current write offset.
public void SetWriteOffset(long offset)
Parameters¶
offset
Int64
The write offset.
Remarks:
This should only be used to set the offset to a known previous location (very carefully), or to 0 so that the next write gets appended to the end of the file.
DataWidth(TiffType)¶
Gets the number of bytes occupied by the item of given type.
public static int DataWidth(TiffType type)
Parameters¶
type
TiffType
The type.
Returns¶
Int32
The number of bytes occupied by the or 0 if unknown data type is supplied.
SwabShort(Int16&)¶
Swaps the bytes in a single 16-bit item.
public static void SwabShort(Int16& value)
Parameters¶
value
Int16&
The value to swap bytes in.
SwabLong(Int32&)¶
Swaps the bytes in a single 32-bit item.
public static void SwabLong(Int32& value)
Parameters¶
value
Int32&
The value to swap bytes in.
SwabDouble(Double&)¶
Swaps the bytes in a single double-precision floating-point number.
public static void SwabDouble(Double& value)
Parameters¶
value
Double&
The value to swap bytes in.
SwabArrayOfShort(Int16[], Int32)¶
Swaps the bytes in specified number of values in the array of 16-bit items.
public static void SwabArrayOfShort(Int16[] array, int count)
Parameters¶
array
Int16[]
The array to swap bytes in.
count
Int32
The number of items to swap bytes in.
SwabArrayOfShort(Int16[], Int32, Int32)¶
Swaps the bytes in specified number of values in the array of 16-bit items starting at specified offset.
public static void SwabArrayOfShort(Int16[] array, int offset, int count)
Parameters¶
array
Int16[]
The array to swap bytes in.
offset
Int32
The zero-based offset in at which to begin swapping bytes.
count
Int32
The number of items to swap bytes in.
SwabArrayOfTriples(Byte[], Int32)¶
Swaps the bytes in specified number of values in the array of triples (24-bit items).
public static void SwabArrayOfTriples(Byte[] array, int count)
Parameters¶
array
Byte[]
The array to swap bytes in.
count
Int32
The number of items to swap bytes in.
SwabArrayOfTriples(Byte[], Int32, Int32)¶
Swaps the bytes in specified number of values in the array of triples (24-bit items) starting at specified offset.
public static void SwabArrayOfTriples(Byte[] array, int offset, int count)
Parameters¶
array
Byte[]
The array to swap bytes in.
offset
Int32
The zero-based offset in at which to begin swapping bytes.
count
Int32
The number of items to swap bytes in.
SwabArrayOfLong(Int32[], Int32)¶
Swaps the bytes in specified number of values in the array of 32-bit items.
public static void SwabArrayOfLong(Int32[] array, int count)
Parameters¶
array
Int32[]
The array to swap bytes in.
count
Int32
The number of items to swap bytes in.
SwabArrayOfLong8(Int64[], Int32)¶
Swaps the bytes in specified number of values in the array of 64-bit items.
public static void SwabArrayOfLong8(Int64[] array, int count)
Parameters¶
array
Int64[]
The array to swap bytes in.
count
Int32
The number of items to swap bytes in.
SwabArrayOfLong(Int32[], Int32, Int32)¶
Swaps the bytes in specified number of values in the array of 32-bit items starting at specified offset.
public static void SwabArrayOfLong(Int32[] array, int offset, int count)
Parameters¶
array
Int32[]
The array to swap bytes in.
offset
Int32
The zero-based offset in at which to begin swapping bytes.
count
Int32
The number of items to swap bytes in.
SwabArrayOfLong8(Int64[], Int32, Int32)¶
Swaps the bytes in specified number of values in the array of 64-bit items starting at specified offset.
public static void SwabArrayOfLong8(Int64[] array, int offset, int count)
Parameters¶
array
Int64[]
The array to swap bytes in.
offset
Int32
The zero-based offset in at which to begin swapping bytes.
count
Int32
The number of items to swap bytes in.
SwabArrayOfDouble(Double[], Int32)¶
Swaps the bytes in specified number of values in the array of double-precision floating-point numbers.
public static void SwabArrayOfDouble(Double[] array, int count)
Parameters¶
array
Double[]
The array to swap bytes in.
count
Int32
The number of items to swap bytes in.
SwabArrayOfDouble(Double[], Int32, Int32)¶
Swaps the bytes in specified number of values in the array of double-precision floating-point numbers starting at specified offset.
public static void SwabArrayOfDouble(Double[] array, int offset, int count)
Parameters¶
array
Double[]
The array to swap bytes in.
offset
Int32
The zero-based offset in at which to begin swapping bytes.
count
Int32
The number of items to swap bytes in.
ReverseBits(Byte[], Int32)¶
Replaces specified number of bytes in with the equivalent bit-reversed bytes.
public static void ReverseBits(Byte[] buffer, int count)
Parameters¶
buffer
Byte[]
The buffer to replace bytes in.
count
Int32
The number of bytes to process.
Remarks:
This operation is performed with a lookup table, which can be retrieved using the Tiff.GetBitRevTable(Boolean) method.
ReverseBits(Byte[], Int32, Int32)¶
Replaces specified number of bytes in with the equivalent bit-reversed bytes starting at specified offset.
public static void ReverseBits(Byte[] buffer, int offset, int count)
Parameters¶
buffer
Byte[]
The buffer to replace bytes in.
offset
Int32
The zero-based offset in at which to begin processing bytes.
count
Int32
The number of bytes to process.
Remarks:
This operation is performed with a lookup table, which can be retrieved using the Tiff.GetBitRevTable(Boolean) method.
GetBitRevTable(Boolean)¶
Retrieves a bit reversal table.
public static Byte[] GetBitRevTable(bool reversed)
Parameters¶
reversed
Boolean
if set to true then bit reversal table will be retrieved; otherwise, the table that do not reverse bit values will be retrieved.
Returns¶
Byte[]
The bit reversal table.
Remarks:
If is false
then the table that do not reverse bit values will be retrieved. It is a lookup table that can be used as an identity function; i.e. NoBitRevTable[n] == n.
ByteArrayToInts(Byte[], Int32, Int32)¶
Converts a byte buffer into array of 32-bit values.
public static Int32[] ByteArrayToInts(Byte[] buffer, int offset, int count)
Parameters¶
buffer
Byte[]
The byte buffer.
offset
Int32
The zero-based offset in at which to begin converting bytes.
count
Int32
The number of bytes to convert.
Returns¶
Int32[]
The array of 32-bit values.
ByteArrayToLong8(Byte[], Int32, Int32)¶
Converts a byte buffer into array of 64-bit values.
public static Int64[] ByteArrayToLong8(Byte[] buffer, int offset, int count)
Parameters¶
buffer
Byte[]
The byte buffer.
offset
Int32
The zero-based offset in at which to begin converting bytes.
count
Int32
The number of bytes to convert.
Returns¶
Int64[]
The array of 64-bit values.
Long8ToByteArray(Int64[], Int32, Int32, Byte[], Int32)¶
Converts array of 64-bit values into array of bytes.
public static void Long8ToByteArray(Int64[] source, int srcOffset, int srcCount, Byte[] bytes, int offset)
Parameters¶
source
Int64[]
The array of 64-bit values.
srcOffset
Int32
The zero-based offset in at which to begin converting bytes.
srcCount
Int32
The number of 64-bit values to convert.
bytes
Byte[]
The byte array to store converted values at.
offset
Int32
The zero-based offset in at which to begin storing converted values.
IntsToByteArray(Int32[], Int32, Int32, Byte[], Int32)¶
Converts array of 32-bit values into array of bytes.
public static void IntsToByteArray(Int32[] source, int srcOffset, int srcCount, Byte[] bytes, int offset)
Parameters¶
source
Int32[]
The array of 32-bit values.
srcOffset
Int32
The zero-based offset in at which to begin converting bytes.
srcCount
Int32
The number of 32-bit values to convert.
bytes
Byte[]
The byte array to store converted values at.
offset
Int32
The zero-based offset in at which to begin storing converted values.
ByteArrayToShorts(Byte[], Int32, Int32)¶
Converts a byte buffer into array of 16-bit values.
public static Int16[] ByteArrayToShorts(Byte[] buffer, int offset, int count)
Parameters¶
buffer
Byte[]
The byte buffer.
offset
Int32
The zero-based offset in at which to begin converting bytes.
count
Int32
The number of bytes to convert.
Returns¶
Int16[]
The array of 16-bit values.
ShortsToByteArray(Int16[], Int32, Int32, Byte[], Int32)¶
Converts array of 16-bit values into array of bytes.
public static void ShortsToByteArray(Int16[] source, int srcOffset, int srcCount, Byte[] bytes, int offset)
Parameters¶
source
Int16[]
The array of 16-bit values.
srcOffset
Int32
The zero-based offset in at which to begin converting bytes.
srcCount
Int32
The number of 16-bit values to convert.
bytes
Byte[]
The byte array to store converted values at.
offset
Int32
The zero-based offset in at which to begin storing converted values.
GetA(Int32)¶
Gets the A component from ABGR value returned by ReadRGBAImage.
public static int GetA(int abgr)
Parameters¶
abgr
Int32
The ABGR value.
Returns¶
Int32
The A component from ABGR value.
FindCodec(Compression)¶
Retrieves the codec registered for the specified compression scheme.
public TiffCodec FindCodec(Compression scheme)
Parameters¶
scheme
Compression
The compression scheme.
Returns¶
TiffCodec
The codec registered for the specified compression scheme or null if there is no codec registered for the given scheme.
Remarks:
LibTiff.Net supports a variety of compression schemes implemented by software codecs. Each codec adheres to a modular interface that provides for the decoding and encoding of image data; as well as some other methods for initialization, setup, cleanup, and the control of default strip and tileView sizes. Codecs are identified by the associated value of the TiffTag.COMPRESSION tag.
Other compression schemes may be registered. Registered schemes can also override the built-in versions provided by the library.
RegisterCodec(TiffCodec)¶
Adds specified codec to a list of registered codec.
public void RegisterCodec(TiffCodec codec)
Parameters¶
codec
TiffCodec
The codec to register.
Remarks:
This method can be used to augment or override the set of codecs available to an application. If the is for a scheme that already has a registered codec then it is overridden and any images with data encoded with this compression scheme will be decoded using the supplied codec.
UnRegisterCodec(TiffCodec)¶
Removes specified codec from a list of registered codecs.
public void UnRegisterCodec(TiffCodec codec)
Parameters¶
codec
TiffCodec
The codec to remove from a list of registered codecs.
IsCodecConfigured(Compression)¶
Checks whether library has working codec for the specific compression scheme.
public bool IsCodecConfigured(Compression scheme)
Parameters¶
scheme
Compression
The scheme to check.
Returns¶
Boolean
true if the codec is configured and working; otherwise, false.
GetConfiguredCodecs()¶
Retrieves an array of configured codecs, both built-in and registered by user.
public TiffCodec[] GetConfiguredCodecs()
Returns¶
TiffCodec[]
An array of configured codecs.
Realloc(Byte[], Int32)¶
Allocates new byte array of specified size and copies data from the existing to the new array.
public static Byte[] Realloc(Byte[] array, int size)
Parameters¶
array
Byte[]
The existing array.
size
Int32
The number of elements in new array.
Returns¶
The new byte array of specified size with data from the existing array.
Realloc(Int32[], Int32)¶
Allocates new integer array of specified size and copies data from the existing to the new array.
public static Int32[] Realloc(Int32[] array, int size)
Parameters¶
array
Int32[]
The existing array.
size
Int32
The number of elements in new array.
Returns¶
The new integer array of specified size with data from the existing array.
Remarks:
Size of the array is in elements, not bytes.
Compare(Int16[], Int16[], Int32)¶
Compares specified number of elements in two arrays.
public static int Compare(Int16[] first, Int16[] second, int elementCount)
Parameters¶
first
Int16[]
The first array to compare.
second
Int16[]
The second array to compare.
elementCount
Int32
The number of elements to compare.
Returns¶
The difference between compared elements or 0 if all elements are equal.
Open(String, String)¶
Initializes new instance of Tiff class and opens a TIFF file for reading or writing.
public static Tiff Open(string fileName, string mode)
Parameters¶
fileName
String
The name of the file to open.
mode
String
The open mode. Specifies if the file is to be opened for reading ("r"), writing ("w"), or appending ("a") and, optionally, whether to override certain default aspects of library operation (see remarks).
Returns¶
Tiff
The new instance of class if specified file is successfully opened; otherwise, null.
Remarks:
Tiff.Open(String, String) opens a TIFF file whose name is . When a file is opened for appending, existing data will not be touched; instead new data will be written as additional subfiles. If an existing file is opened for writing, all previous data is overwritten.
If a file is opened for reading, the first TIFF directory in the file is automatically read (see Tiff.SetDirectory(Int16) for reading directories other than the first). If a file is opened for writing or appending, a default directory is automatically created for writing subsequent data. This directory has all the default values specified in TIFF Revision 6.0: BitsPerSample = 1, ThreshHolding = Threshold.BILEVEL (bilevel art scan), FillOrder = MSB2LSB (most significant bit of each data byte is filled first), Orientation = TOPLEFT (the 0th row represents the visual top of the image, and the 0th column represents the visual left hand side), SamplesPerPixel = 1, RowsPerStrip = infinity, ResolutionUnit = INCH, and Compression = NONE. To alter these values, or to define values for additional fields, Tiff.SetField(TiffTag, Object[]) must be used.
The parameter can include the following flags in addition to the "r", "w", and "a" flags. Note however that option flags must follow the read-write-append specification.
FlagDescriptionlWhen creating a new file force information be written with Little-Endian byte order (but see below).bWhen creating a new file force information be written with Big-Endian byte order (but see below).LForce image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way the library has worked from its inception.BForce image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB); this is the default.HForce image data that is read or written to be treated with bits filled in the same order as the native CPU.CEnable the use of "strip chopping" when reading images that are comprised of a single strip or tileView of uncompressed data. Strip chopping is a mechanism by which the library will automatically convert the single-strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in its entirety. Strip chopping does however alter the apparent contents of the image because when an image is divided into multiple strips it looks as though the underlying file contains multiple separate strips. The default behaviour is to enable strip chopping.cDisable the use of strip chopping when reading images.hRead TIFF header only, do not load the first image directory. That could be useful in case of the broken first directory. We can open the file and proceed to the other directories.
By default the library will create new files with the native byte-order of the CPU on which the application is run. This ensures optimal performance and is portable to any application that conforms to the TIFF specification. To force the library to use a specific byte-order when creating a new file the "b" and "l" option flags may be included in the parameter; for example, "wb" or "wl".
The use of the "l" and "b" flags is strongly discouraged. These flags are provided solely because numerous vendors do not correctly support TIFF; they only support one of the two byte orders. It is strongly recommended that you not use this feature except to deal with busted apps that write invalid TIFF.
The "L", "B", and "H" flags are intended for applications that can optimize operations on data by using a particular bit order. By default the library returns data in MSB2LSB bit order. Returning data in the bit order of the native CPU makes the most sense but also requires applications to check the value of the TiffTag.FILLORDER tag; something they probably do not do right now.
The "c" option permits applications that only want to look at the tags, for example, to get the unadulterated TIFF tag information.
ClientOpen(String, String, Object, TiffStream)¶
Initializes new instance of Tiff class and opens a stream with TIFF data for reading or writing.
public static Tiff ClientOpen(string name, string mode, object clientData, TiffStream stream)
Parameters¶
name
String
The name for the new instance of class.
mode
String
The open mode. Specifies if the file is to be opened for reading ("r"), writing ("w"), or appending ("a") and, optionally, whether to override certain default aspects of library operation (see remarks for method for the list of the mode flags).
clientData
Object
Some client data. This data is passed as parameter to every method of the object specified by the parameter.
stream
TiffStream
An instance of the class to use for reading, writing and seeking of TIFF data.
Returns¶
Tiff
The new instance of class if stream is successfully opened; otherwise, null.
Remarks:
This method can be used to read TIFF data from sources other than file. When custom stream class derived from TiffStream is used it is possible to read (or write) TIFF data that reside in memory, database, etc.
Please note, that is an arbitrary string used as ID for the created Tiff. It's not required to be a file name or anything meaningful at all.
Please read remarks for Tiff.Open(String, String) method for the list of option flags that can be specified in parameter.
Close()¶
Closes a previously opened TIFF file.
public void Close()
Remarks:
This method closes a file or stream that was previously opened with Tiff.Open(String, String) or Tiff.ClientOpen(String, String, Object, TiffStream). Any buffered data are flushed to the file/stream, including the contents of the current directory (if modified); and all resources are reclaimed.
Dispose()¶
Frees and releases all resources allocated by this Tiff.
public void Dispose()
GetTagListCount()¶
Gets the number of elements in the custom tag list.
public int GetTagListCount()
Returns¶
Int32
The number of elements in the custom tag list.
GetTagListEntry(Int32)¶
Retrieves the custom tag with specified index.
public int GetTagListEntry(int index)
Parameters¶
index
Int32
The zero-based index of a custom tag to retrieve.
Returns¶
Int32
The custom tag with specified index.
MergeFieldInfo(TiffFieldInfo[], Int32)¶
Merges given field information to existing one.
public void MergeFieldInfo(TiffFieldInfo[] info, int count)
Parameters¶
info
TiffFieldInfo[]
The array of objects.
count
Int32
The number of items to use from the array.
FindFieldInfo(TiffTag, TiffType)¶
Retrieves field information for the specified tag.
public TiffFieldInfo FindFieldInfo(TiffTag tag, TiffType type)
Parameters¶
tag
TiffTag
The tag to retrieve field information for.
type
TiffType
The tiff data type to use us additional filter.
Returns¶
TiffFieldInfo
The field information for specified tag with specified type or null if the field information wasn't found.
FindFieldInfoByName(String, TiffType)¶
Retrieves field information for the tag with specified name.
public TiffFieldInfo FindFieldInfoByName(string name, TiffType type)
Parameters¶
name
String
The name of the tag to retrieve field information for.
type
TiffType
The tiff data type to use us additional filter.
Returns¶
TiffFieldInfo
The field information for specified tag with specified type or null if the field information wasn't found.
FieldWithTag(TiffTag)¶
Retrieves field information for the specified tag.
public TiffFieldInfo FieldWithTag(TiffTag tag)
Parameters¶
tag
TiffTag
The tag to retrieve field information for.
Returns¶
TiffFieldInfo
The field information for specified tag or null if the field information wasn't found.
FieldWithName(String)¶
Retrieves field information for the tag with specified name.
public TiffFieldInfo FieldWithName(string name)
Parameters¶
name
String
The name of the tag to retrieve field information for.
Returns¶
TiffFieldInfo
The field information for specified tag or null if the field information wasn't found.
GetTagMethods()¶
Gets the currently used tag methods.
public TiffTagMethods GetTagMethods()
Returns¶
TiffTagMethods
The currently used tag methods.
SetTagMethods(TiffTagMethods)¶
Sets the new tag methods to use.
public TiffTagMethods SetTagMethods(TiffTagMethods methods)
Parameters¶
methods
TiffTagMethods
Tag methods.
Returns¶
TiffTagMethods
The previously used tag methods.
GetClientInfo(String)¶
Gets the extra information with specified name associated with this Tiff.
public object GetClientInfo(string name)
Parameters¶
name
String
Name of the extra information to retrieve.
Returns¶
Object
The extra information with specified name associated with this or null if extra information with specified name was not found.
SetClientInfo(Object, String)¶
Associates extra information with this Tiff.
public void SetClientInfo(object data, string name)
Parameters¶
data
Object
The information to associate with this .
name
String
The name (label) of the information.
Remarks:
If there is already an extra information with the name specified by it will be replaced by the information specified by .
Flush()¶
Flushes pending writes to an open TIFF file.
public bool Flush()
Returns¶
Boolean
true if succeeded; otherwise, false
Remarks:
causes any pending writes for the specified file (including writes for the current directory) to be done. In normal operation this call is never needed − the library automatically does any flushing required.
FlushData()¶
Flushes any pending image data for the specified file to be written out.
public bool FlushData()
Returns¶
Boolean
true if succeeded; otherwise, false
Remarks:
flushes any pending image data for the specified file to be written out; directory-related data are not flushed. In normal operation this call is never needed − the library automatically does any flushing required.
GetField(TiffTag)¶
Gets the value(s) of a tag in an open TIFF file.
public FieldValue[] GetField(TiffTag tag)
Parameters¶
tag
TiffTag
The tag.
Returns¶
FieldValue[]
The value(s) of a tag in an open TIFF file as array of objects or null if there is no such tag set.
Remarks:
Tiff.GetField(TiffTag) returns the value(s) of a tag or pseudo-tag associated with the current directory of the opened TIFF file. The tag is identified by . The type and number of values returned is dependent on the tag being requested. You may want to consult "Well-known tags and their value(s) data types" to become familiar with exact data types and calling conventions required for each tag supported by the library.
A pseudo-tag is a parameter that is used to control the operation of the library but whose value is not read or written to the underlying file.
GetFieldDefaulted(TiffTag)¶
Gets the value(s) of a tag in an open TIFF file or default value(s) of a tag if a tag is not defined in the current directory and it has a default value(s).
public FieldValue[] GetFieldDefaulted(TiffTag tag)
Parameters¶
tag
TiffTag
The tag.
Returns¶
The value(s) of a tag in an open TIFF file as array of
objects or null if there is no such tag set and
tag has no default value.
Remarks:
Tiff.GetFieldDefaulted(TiffTag) returns the value(s) of a tag or pseudo-tag associated with the current directory of the opened TIFF file or default value(s) of a tag if a tag is not defined in the current directory and it has a default value(s). The tag is identified by . The type and number of values returned is dependent on the tag being requested. You may want to consult "Well-known tags and their value(s) data types" to become familiar with exact data types and calling conventions required for each tag supported by the library.
A pseudo-tag is a parameter that is used to control the operation of the library but whose value is not read or written to the underlying file.
ReadDirectory()¶
Reads the contents of the next TIFF directory in an open TIFF file/stream and makes it the current directory.
public bool ReadDirectory()
Returns¶
Boolean
true if directory was successfully read; otherwise, false if an error was encountered, or if there are no more directories to be read.
Remarks:
Directories are read sequentially.
Applications only need to call to read multiple subfiles in a single TIFF file/stream - the first directory in a file/stream is automatically read when Tiff.Open(String, String) or Tiff.ClientOpen(String, String, Object, TiffStream) is called.
The images that have a single uncompressed strip or tileView of data are automatically treated as if they were made up of multiple strips or tiles of approximately 8 kilobytes each. This operation is done only in-memory; it does not alter the contents of the file/stream. However, the construction of the "chopped strips" is visible to the application through the number of strips returned by or the number of tiles returned by .
ReadCustomDirectory(Int64, TiffFieldInfo[], Int32)¶
Reads a custom directory from the arbitrary offset within file/stream.
public bool ReadCustomDirectory(long offset, TiffFieldInfo[] info, int count)
Parameters¶
offset
Int64
The directory offset.
info
TiffFieldInfo[]
The array of objects to read from custom directory. Standard objects are ignored.
count
Int32
The number of items to use from the array.
Returns¶
Boolean
true if a custom directory was read successfully; otherwise, false
ReadEXIFDirectory(Int64)¶
Reads an EXIF directory from the given offset within file/stream.
public bool ReadEXIFDirectory(long offset)
Parameters¶
offset
Int64
The directory offset.
Returns¶
Boolean
true if an EXIF directory was read successfully; otherwise, false
ScanlineSize()¶
Calculates the size in bytes of a row of data as it would be returned in a call to , or as it would be expected in a call to .
public int ScanlineSize()
Returns¶
Int32
The size in bytes of a row of data.
Remarks:
ScanlineSize calculates size for one sample plane only. Please use if you want to get size in bytes of a complete decoded and packed raster scanline.
RasterScanlineSize()¶
Calculates the size in bytes of a complete decoded and packed raster scanline.
public int RasterScanlineSize()
Returns¶
Int32
The size in bytes of a complete decoded and packed raster scanline.
Remarks:
The value returned by RasterScanlineSize may be different from the value returned by if data is stored as separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).
DefaultStripSize(Int32)¶
Computes the number of rows for a reasonable-sized strip according to the current settings of the TiffTag.IMAGEWIDTH, TiffTag.BITSPERSAMPLE and TiffTag.SAMPLESPERPIXEL tags and any compression-specific requirements.
public int DefaultStripSize(int estimate)
Parameters¶
estimate
Int32
The esimated value (may be zero).
Returns¶
Int32
The number of rows for a reasonable-sized strip according to the current tag settings and compression-specific requirements.
Remarks:
If the parameter is non-zero, then it is taken as an estimate of the desired strip size and adjusted according to any compression-specific requirements. The value returned by DefaultStripSize is typically used to define the TiffTag.ROWSPERSTRIP tag. If there is no any unusual requirements DefaultStripSize tries to create strips that have approximately 8 kilobytes of uncompressed data.
StripSize()¶
Computes the number of bytes in a row-aligned strip.
public int StripSize()
Returns¶
Int32
The number of bytes in a row-aligned strip
Remarks:
StripSize returns the equivalent size for a strip of data as it would be returned in a call to Tiff.ReadEncodedStrip(Int32, Byte[], Int32, Int32) or as it would be expected in a call to .
If the value of the field corresponding to TiffTag.ROWSPERSTRIP is larger than the recorded TiffTag.IMAGELENGTH, then the strip size is truncated to reflect the actual space required to hold the strip.
VStripSize(Int32)¶
Computes the number of bytes in a row-aligned strip with specified number of rows.
public int VStripSize(int rowCount)
Parameters¶
rowCount
Int32
The number of rows in a strip.
Returns¶
The number of bytes in a row-aligned strip with specified number of rows.
RawStripSize(Int32)¶
Computes the number of bytes in a raw (i.e. not decoded) strip.
public long RawStripSize(int strip)
Parameters¶
strip
Int32
The zero-based index of a strip.
Returns¶
Int64
The number of bytes in a raw strip.
ComputeStrip(Int32, Int16)¶
Computes which strip contains the specified coordinates (row, plane).
public int ComputeStrip(int row, short plane)
Parameters¶
row
Int32
The row.
plane
Int16
The sample plane.
Returns¶
Int32
The number of the strip that contains the specified coordinates.
Remarks:
A valid strip number is always returned; out-of-range coordinate values are clamped to the bounds of the image. The parameter is always used in calculating a strip. The parameter is used only if data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).
NumberOfStrips()¶
Retrives the number of strips in the image.
public int NumberOfStrips()
Returns¶
Int32
The number of strips in the image.
DefaultTileSize(Int32&, Int32&)¶
Computes the pixel width and height of a reasonable-sized tileView suitable for setting up the TiffTag.TILEWIDTH and TiffTag.TILELENGTH tags.
public void DefaultTileSize(Int32& width, Int32& height)
Parameters¶
width
Int32&
The proposed tileView width upon the call / tileView width to use after the call.
height
Int32&
The proposed tileView height upon the call / tileView height to use after the call.
Remarks:
If the and values passed in are non-zero, then they are adjusted to reflect any compression-specific requirements. The returned width and height are constrained to be a multiple of 16 pixels to conform with the TIFF specification.
TileSize()¶
Compute the number of bytes in a row-aligned tileView.
public int TileSize()
Returns¶
Int32
The number of bytes in a row-aligned tileView.
Remarks:
TileSize returns the equivalent size for a tileView of data as it would be returned in a call to Tiff.ReadTile(Byte[], Int32, Int32, Int32, Int32, Int16) or as it would be expected in a call to .
VTileSize(Int32)¶
Computes the number of bytes in a row-aligned tileView with specified number of rows.
public int VTileSize(int rowCount)
Parameters¶
rowCount
Int32
The number of rows in a tileView.
Returns¶
The number of bytes in a row-aligned tileView with specified number of rows.
RawTileSize(Int32)¶
Computes the number of bytes in a raw (i.e. not decoded) tileView.
public long RawTileSize(int tile)
Parameters¶
tile
Int32
The zero-based index of a tileView.
Returns¶
Int64
The number of bytes in a raw tileView.
TileRowSize()¶
Compute the number of bytes in each row of a tileView.
public int TileRowSize()
Returns¶
Int32
The number of bytes in each row of a tileView.
ComputeTile(Int32, Int32, Int32, Int16)¶
Computes which tileView contains the specified coordinates (x, y, z, plane).
public int ComputeTile(int x, int y, int z, short plane)
Parameters¶
x
Int32
The x-coordinate.
y
Int32
The y-coordinate.
z
Int32
The z-coordinate.
plane
Int16
The sample plane.
Returns¶
Int32
The number of the tileView that contains the specified coordinates.
Remarks:
A valid tileView number is always returned; out-of-range coordinate values are clamped to the bounds of the image. The and parameters are always used in calculating a tileView. The parameter is used if the image is deeper than 1 slice (TiffTag.IMAGEDEPTH > 1). The parameter is used only if data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).
CheckTile(Int32, Int32, Int32, Int16)¶
Checks whether the specified (x, y, z, plane) coordinates are within the bounds of the image.
public bool CheckTile(int x, int y, int z, short plane)
Parameters¶
x
Int32
The x-coordinate.
y
Int32
The y-coordinate.
z
Int32
The z-coordinate.
plane
Int16
The sample plane.
Returns¶
Boolean
true if the specified coordinates are within the bounds of the image; otherwise, false.
Remarks:
The parameter is checked against the value of the TiffTag.IMAGEWIDTH tag. The parameter is checked against the value of the TiffTag.IMAGELENGTH tag. The parameter is checked against the value of the TiffTag.IMAGEDEPTH tag (if defined). The parameter is checked against the value of the TiffTag.SAMPLESPERPIXEL tag if the data are organized in separate planes.
NumberOfTiles()¶
Retrives the number of tiles in the image.
public int NumberOfTiles()
Returns¶
Int32
The number of tiles in the image.
Clientdata()¶
Returns the custom client data associated with this Tiff.
public object Clientdata()
Returns¶
Object
The custom client data associated with this .
SetClientdata(Object)¶
Asscociates a custom data with this Tiff.
public object SetClientdata(object data)
Parameters¶
data
Object
The data to associate.
Returns¶
Object
The previously associated data.
GetMode()¶
Gets the mode with which the underlying file or stream was opened.
public int GetMode()
Returns¶
Int32
The mode with which the underlying file or stream was opened.
SetMode(Int32)¶
Sets the new mode for the underlying file or stream.
public int SetMode(int mode)
Parameters¶
mode
Int32
The new mode for the underlying file or stream.
Returns¶
Int32
The previous mode with which the underlying file or stream was opened.
IsTiled()¶
Gets the value indicating whether the image data of this Tiff has a tiled organization.
public bool IsTiled()
Returns¶
Boolean
true if the image data of this has a tiled organization or false if the image data of this is organized in strips.
IsByteSwapped()¶
Gets the value indicating whether the image data was in a different byte-order than the host computer.
public bool IsByteSwapped()
Returns¶
Boolean
true if the image data was in a different byte-order than the host computer or false if the TIFF file/stream and local host byte-orders are the same.
Remarks:
Note that Tiff.ReadTile(Byte[], Int32, Int32, Int32, Int32, Int16), Tiff.ReadEncodedTile(Int32, Byte[], Int32, Int32), Tiff.ReadEncodedStrip(Int32, Byte[], Int32, Int32) and methods already normally perform byte swapping to local host order if needed.
Also note that Tiff.ReadRawTile(Int32, Byte[], Int32, Int32) and Tiff.ReadRawStrip(Int32, Byte[], Int32, Int32) do not perform byte swapping to local host order.
IsUpSampled()¶
Gets the value indicating whether the image data returned through the read interface methods is being up-sampled.
public bool IsUpSampled()
Returns¶
Boolean
true if the data is returned up-sampled; otherwise, false.
Remarks:
The value returned by this method can be useful to applications that want to calculate I/O buffer sizes to reflect this usage (though the usual strip and tileView size routines already do this).
IsMSB2LSB()¶
Gets the value indicating whether the image data is being returned in MSB-to-LSB bit order.
public bool IsMSB2LSB()
Returns¶
Boolean
true if the data is being returned in MSB-to-LSB bit order (i.e with bit 0 as the most significant bit); otherwise, false.
IsBigEndian()¶
Gets the value indicating whether given image data was written in big-endian order.
public bool IsBigEndian()
Returns¶
Boolean
true if given image data was written in big-endian order; otherwise, false.
GetStream()¶
Gets the tiff stream.
public TiffStream GetStream()
Returns¶
TiffStream
The tiff stream.
CurrentRow()¶
Gets the current row that is being read or written.
public int CurrentRow()
Returns¶
Int32
The current row that is being read or written.
Remarks:
The current row is updated each time a read or write is done.
CurrentDirectory()¶
Gets the zero-based index of the current directory.
public short CurrentDirectory()
Returns¶
Int16
The zero-based index of the current directory.
Remarks:
The zero-based index returned by this method is suitable for use with the Tiff.SetDirectory(Int16) method.
NumberOfDirectories()¶
Gets the number of directories in a file.
public short NumberOfDirectories()
Returns¶
Int16
The number of directories in a file.
CurrentDirOffset()¶
Retrieves the file/stream offset of the current directory.
public long CurrentDirOffset()
Returns¶
Int64
The file/stream offset of the current directory.
CurrentStrip()¶
Gets the current strip that is being read or written.
public int CurrentStrip()
Returns¶
Int32
The current strip that is being read or written.
Remarks:
The current strip is updated each time a read or write is done.
CurrentTile()¶
Gets the current tileView that is being read or written.
public int CurrentTile()
Returns¶
Int32
The current tileView that is being read or written.
Remarks:
The current tileView is updated each time a read or write is done.
ReadBufferSetup(Byte[], Int32)¶
Sets up the data buffer used to read raw (encoded) data from a file.
public void ReadBufferSetup(Byte[] buffer, int size)
Parameters¶
buffer
Byte[]
The data buffer.
size
Int32
The buffer size.
Remarks:
This method is provided for client-control of the I/O buffers used by the library. Applications need never use this method; it's provided only for "intelligent clients" that wish to optimize memory usage and/or eliminate potential copy operations that can occur when working with images that have data stored without compression.
If the is null
, then a buffer of appropriate size is allocated by the library. Otherwise, the caller must guarantee that the buffer is large enough to hold any individual strip of raw data.
WriteBufferSetup(Byte[], Int32)¶
Sets up the data buffer used to write raw (encoded) data to a file.
public void WriteBufferSetup(Byte[] buffer, int size)
Parameters¶
buffer
Byte[]
The data buffer.
size
Int32
The buffer size.
Remarks:
This method is provided for client-control of the I/O buffers used by the library. Applications need never use this method; it's provided only for "intelligent clients" that wish to optimize memory usage and/or eliminate potential copy operations that can occur when working with images that have data stored without compression.
If the is -1 then the buffer size is selected to hold a complete tileView or strip, or at least 8 kilobytes, whichever is greater. If the is null
, then a buffer of appropriate size is allocated by the library.
SetupStrips()¶
Setups the strips.
public bool SetupStrips()
Returns¶
Boolean
true if setup successfully; otherwise, false
WriteCheck(Boolean, String)¶
Verifies that file/stream is writable and that the directory information is setup properly.
public bool WriteCheck(bool tiles, string method)
Parameters¶
tiles
Boolean
If set to true then ability to write tiles will be verified; otherwise, ability to write strips will be verified.
method
String
The name of the calling method.
Returns¶
Boolean
true if file/stream is writeable and the directory information is setup properly; otherwise, false
FreeDirectory()¶
Releases storage associated with current directory.
public void FreeDirectory()
CreateDirectory()¶
Creates a new directory within file/stream.
public void CreateDirectory()
Remarks:
The newly created directory will not exist on the file/stream till , , or is called.
LastDirectory()¶
Returns an indication of whether the current directory is the last directory in the file.
public bool LastDirectory()
Returns¶
Boolean
true if current directory is the last directory in the file; otherwise, false.
SetDirectory(Int16)¶
Sets the directory with specified number as the current directory.
public bool SetDirectory(short number)
Parameters¶
number
Int16
The zero-based number of the directory to set as the current directory.
Returns¶
Boolean
true if the specified directory was set as current successfully; otherwise, false
Remarks:
SetDirectory changes the current directory and reads its contents with .
SetSubDirectory(Int64)¶
Sets the directory at specified file/stream offset as the current directory.
public bool SetSubDirectory(long offset)
Parameters¶
offset
Int64
The offset from the beginnig of the file/stream to the directory to set as the current directory.
Returns¶
Boolean
true if the directory at specified file offset was set as current successfully; otherwise, false
Remarks:
SetSubDirectory acts like Tiff.SetDirectory(Int16), except the directory is specified as a file offset instead of an index; this is required for accessing subdirectories linked through a SubIFD tag (e.g. thumbnail images).
UnlinkDirectory(Int16)¶
Unlinks the specified directory from the directory chain.
public bool UnlinkDirectory(short number)
Parameters¶
number
Int16
The zero-based number of the directory to unlink.
Returns¶
Boolean
true if directory was unlinked successfully; otherwise, false.
Remarks:
UnlinkDirectory does not removes directory bytes from the file/stream. It only makes them unused.
SetField(TiffTag, Object[])¶
Sets the value(s) of a tag in a TIFF file/stream open for writing.
public bool SetField(TiffTag tag, Object[] value)
Parameters¶
tag
TiffTag
The tag.
value
Object[]
The tag value(s).
Returns¶
Boolean
true if tag value(s) were set successfully; otherwise, false.
Remarks:
SetField sets the value of a tag or pseudo-tag in the current directory associated with the open TIFF file/stream. To set the value of a field the file/stream must have been previously opened for writing with Tiff.Open(String, String) or Tiff.ClientOpen(String, String, Object, TiffStream); pseudo-tags can be set whether the file was opened for reading or writing. The tag is identified by . The type and number of values in is dependent on the tag being set. You may want to consult "Well-known tags and their value(s) data types" to become familiar with exact data types and calling conventions required for each tag supported by the library.
A pseudo-tag is a parameter that is used to control the operation of the library but whose value is not read or written to the underlying file.
The field will be written to the file when/if the directory structure is updated.
WriteDirectory()¶
Writes the contents of the current directory to the file and setup to create a new subfile (page) in the same file.
public bool WriteDirectory()
Returns¶
Boolean
true if the current directory was written successfully; otherwise, false
Remarks:
Applications only need to call WriteDirectory when writing multiple subfiles (pages) to a single TIFF file. WriteDirectory is automatically called by and to write a modified directory if the file is open for writing.
CheckpointDirectory()¶
Writes the current state of the TIFF directory into the file to make what is currently in the file/stream readable.
public bool CheckpointDirectory()
Returns¶
Boolean
true if the current directory was rewritten successfully; otherwise, false
Remarks:
Unlike , CheckpointDirectory does not free up the directory data structures in memory, so they can be updated (as strips/tiles are written) and written again. Reading such a partial file you will at worst get a TIFF read error for the first strip/tileView encountered that is incomplete, but you will at least get all the valid data in the file before that. When the file is complete, just use as usual to finish it off cleanly.
RewriteDirectory()¶
Rewrites the contents of the current directory to the file and setup to create a new subfile (page) in the same file.
public bool RewriteDirectory()
Returns¶
Boolean
true if the current directory was rewritten successfully; otherwise, false
Remarks:
The RewriteDirectory operates similarly to , but can be called with directories previously read or written that already have an established location in the file. It will rewrite the directory, but instead of place it at it's old location (as would) it will place them at the end of the file, correcting the pointer from the preceeding directory or file header to point to it's new location. This is particularly important in cases where the size of the directory and pointed to data has grown, so it won’t fit in the space available at the old location. Note that this will result in the loss of the previously used directory space.
PrintDirectory(Stream)¶
Prints formatted description of the contents of the current directory to the specified stream.
public void PrintDirectory(Stream stream)
Parameters¶
stream
Stream
The stream.
PrintDirectory(Stream, TiffPrintFlags)¶
Prints formatted description of the contents of the current directory to the specified stream using specified print (formatting) options.
public void PrintDirectory(Stream stream, TiffPrintFlags flags)
Parameters¶
stream
Stream
The stream.
flags
TiffPrintFlags
The print (formatting) options.
ReadScanline(Byte[], Int32)¶
Reads and decodes a scanline of data from an open TIFF file/stream.
public bool ReadScanline(Byte[] buffer, int row)
Parameters¶
buffer
Byte[]
The buffer to place read and decoded image data to.
row
Int32
The zero-based index of scanline (row) to read.
Returns¶
Boolean
true if image data were read and decoded successfully; otherwise, false
Remarks:
ReadScanline reads the data for the specified into the user supplied data buffer . The data are returned decompressed and, in the native byte- and bit-ordering, but are otherwise packed (see further below). The must be large enough to hold an entire scanline of data. Applications should call the to find out the size (in bytes) of a scanline buffer. Applications should use Tiff.ReadScanline(Byte[], Int32, Int16) or Tiff.ReadScanline(Byte[], Int32, Int32, Int16) and specify correct sample plane if image data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the value of TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
ReadScanline(Byte[], Int32, Int16)¶
Reads and decodes a scanline of data from an open TIFF file/stream.
public bool ReadScanline(Byte[] buffer, int row, short plane)
Parameters¶
buffer
Byte[]
The buffer to place read and decoded image data to.
row
Int32
The zero-based index of scanline (row) to read.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Boolean
true if image data were read and decoded successfully; otherwise, false
Remarks:
ReadScanline reads the data for the specified and specified sample plane into the user supplied data buffer . The data are returned decompressed and, in the native byte- and bit-ordering, but are otherwise packed (see further below). The must be large enough to hold an entire scanline of data. Applications should call the to find out the size (in bytes) of a scanline buffer. Applications may use Tiff.ReadScanline(Byte[], Int32) or specify 0 for parameter if image data is contiguous (i.e not organized in separate planes, TiffTag.PLANARCONFIG = PlanarConfig.CONTIG).
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the value of TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
ReadScanline(Byte[], Int32, Int32, Int16)¶
Reads and decodes a scanline of data from an open TIFF file/stream.
public bool ReadScanline(Byte[] buffer, int offset, int row, short plane)
Parameters¶
buffer
Byte[]
The buffer to place read and decoded image data to.
offset
Int32
The zero-based byte offset in at which to begin storing read and decoded bytes.
row
Int32
The zero-based index of scanline (row) to read.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Boolean
true if image data were read and decoded successfully; otherwise, false
Remarks:
ReadScanline reads the data for the specified and specified sample plane into the user supplied data buffer . The data are returned decompressed and, in the native byte- and bit-ordering, but are otherwise packed (see further below). The must be large enough to hold an entire scanline of data. Applications should call the to find out the size (in bytes) of a scanline buffer. Applications may use Tiff.ReadScanline(Byte[], Int32) or specify 0 for parameter if image data is contiguous (i.e not organized in separate planes, TiffTag.PLANARCONFIG = PlanarConfig.CONTIG).
The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the value of TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.
WriteScanline(Byte[], Int32)¶
Encodes and writes a scanline of data to an open TIFF file/stream.
public bool WriteScanline(Byte[] buffer, int row)
Parameters¶
buffer
Byte[]
The buffer with image data to be encoded and written.
row
Int32
The zero-based index of scanline (row) to place encoded data at.
Returns¶
Boolean
true if image data were encoded and written successfully; otherwise, false
Remarks:
WriteScanline encodes and writes to a file at the specified . Applications should use Tiff.WriteScanline(Byte[], Int32, Int16) or Tiff.WriteScanline(Byte[], Int32, Int32, Int16) and specify correct sample plane parameter if image data in a file/stream is organized in separate planes (i.e TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).
The data are assumed to be uncompressed and in the native bit- and byte-order of the host machine. The data written to the file is compressed according to the compression scheme of the current TIFF directory (see further below). If the current scanline is past the end of the current subfile, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the scanline (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8. The library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order.
Once data are written to a file/stream for the current directory, the values of certain tags may not be altered; see "Well-known tags and their value(s) data types" for more information.
It is not possible to write scanlines to a file/stream that uses a tiled organization. The can be used to determine if the file/stream is organized as tiles or strips.
WriteScanline(Byte[], Int32, Int16)¶
Encodes and writes a scanline of data to an open TIFF file/stream.
public bool WriteScanline(Byte[] buffer, int row, short plane)
Parameters¶
buffer
Byte[]
The buffer with image data to be encoded and written.
row
Int32
The zero-based index of scanline (row) to place encoded data at.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Boolean
true if image data were encoded and written successfully; otherwise, false
Remarks:
WriteScanline encodes and writes to a file at the specified and specified sample plane . Applications may use Tiff.WriteScanline(Byte[], Int32) or specify 0 for parameter if image data in a file/stream is contiguous (i.e not organized in separate planes, TiffTag.PLANARCONFIG = PlanarConfig.CONTIG).
The data are assumed to be uncompressed and in the native bit- and byte-order of the host machine. The data written to the file is compressed according to the compression scheme of the current TIFF directory (see further below). If the current scanline is past the end of the current subfile, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the scanline (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8. The library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order.
Once data are written to a file/stream for the current directory, the values of certain tags may not be altered; see "Well-known tags and their value(s) data types" for more information.
It is not possible to write scanlines to a file/stream that uses a tiled organization. The can be used to determine if the file/stream is organized as tiles or strips.
WriteScanline(Byte[], Int32, Int32, Int16)¶
Encodes and writes a scanline of data to an open TIFF file/stream.
public bool WriteScanline(Byte[] buffer, int offset, int row, short plane)
Parameters¶
buffer
Byte[]
The buffer with image data to be encoded and written.
offset
Int32
The zero-based byte offset in at which to begin reading bytes.
row
Int32
The zero-based index of scanline (row) to place encoded data at.
plane
Int16
The zero-based index of the sample plane.
Returns¶
Boolean
true if image data were encoded and written successfully; otherwise, false
Remarks:
WriteScanline encodes and writes to a file at the specified and specified sample plane . Applications may use Tiff.WriteScanline(Byte[], Int32) or specify 0 for parameter if image data in a file/stream is contiguous (i.e not organized in separate planes, TiffTag.PLANARCONFIG = PlanarConfig.CONTIG).
The data are assumed to be uncompressed and in the native bit- and byte-order of the host machine. The data written to the file is compressed according to the compression scheme of the current TIFF directory (see further below). If the current scanline is past the end of the current subfile, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the scanline (except for TiffTag.PLANARCONFIG = PlanarConfig.CONTIG, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.
The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8. The library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order.
Once data are written to a file/stream for the current directory, the values of certain tags may not be altered; see "Well-known tags and their value(s) data types" for more information.
It is not possible to write scanlines to a file/stream that uses a tiled organization. The can be used to determine if the file/stream is organized as tiles or strips.
SwabUInt(UInt32&)¶
internal static void SwabUInt(UInt32& lp)
Parameters¶
lp
UInt32&
Realloc(UInt64[], Int32, Int32)¶
internal static UInt64[] Realloc(UInt64[] buffer, int elementCount, int newElementCount)
Parameters¶
buffer
UInt64[]
elementCount
Int32
newElementCount
Int32
Returns¶
Realloc(TiffFieldInfo[], Int32, Int32)¶
internal static TiffFieldInfo[] Realloc(TiffFieldInfo[] buffer, int elementCount, int newElementCount)
Parameters¶
buffer
TiffFieldInfo[]
elementCount
Int32
newElementCount
Int32
Returns¶
Realloc(TiffTagValue[], Int32, Int32)¶
internal static TiffTagValue[] Realloc(TiffTagValue[] buffer, int elementCount, int newElementCount)
Parameters¶
buffer
TiffTagValue[]
elementCount
Int32
newElementCount
Int32
Returns¶
setCompressionScheme(Compression)¶
internal bool setCompressionScheme(Compression scheme)
Parameters¶
scheme
Compression
Returns¶
fillStrip(Int32)¶
Read the specified strip and setup for decoding. The data buffer is expanded, as necessary, to hold the strip's data.
internal bool fillStrip(int strip)
Parameters¶
strip
Int32
Returns¶
fillTile(Int32)¶
Read the specified tileView and setup for decoding. The data buffer is expanded, as necessary, to hold the tileView's data.
internal bool fillTile(int tile)
Parameters¶
tile
Int32
Returns¶
newScanlineSize()¶
internal int newScanlineSize()
Returns¶
oldScanlineSize()¶
internal int oldScanlineSize()
Returns¶
flushData1()¶
internal bool flushData1()
Returns¶
GetVersion()¶
Gets the library version string.
public static string GetVersion()
Returns¶
String
The library version string.
GetR(Int32)¶
Gets the R component from ABGR value returned by ReadRGBAImage.
public static int GetR(int abgr)
Parameters¶
abgr
Int32
The ABGR value.
Returns¶
Int32
The R component from ABGR value.
GetG(Int32)¶
Gets the G component from ABGR value returned by ReadRGBAImage.
public static int GetG(int abgr)
Parameters¶
abgr
Int32
The ABGR value.
Returns¶
Int32
The G component from ABGR value.
GetB(Int32)¶
Gets the B component from ABGR value returned by ReadRGBAImage.
public static int GetB(int abgr)
Parameters¶
abgr
Int32
The ABGR value.
Returns¶
Int32
The B component from ABGR value.
readULong(Byte[], Int32)¶
internal static ulong readULong(Byte[] buffer, int offset)
Parameters¶
buffer
Byte[]
offset
Int32
Returns¶
readInt(Byte[], Int32)¶
internal static int readInt(Byte[] buffer, int offset)
Parameters¶
buffer
Byte[]
offset
Int32
Returns¶
writeInt(Int32, Byte[], Int32)¶
internal static void writeInt(int value, Byte[] buffer, int offset)
Parameters¶
value
Int32
buffer
Byte[]
offset
Int32
writeULong(UInt64, Byte[], Int32)¶
internal static void writeULong(ulong value, Byte[] buffer, int offset)
Parameters¶
value
UInt64
buffer
Byte[]
offset
Int32
readShort(Byte[], Int32)¶
internal static short readShort(Byte[] buffer, int offset)
Parameters¶
buffer
Byte[]
offset
Int32
Returns¶
fprintf(Stream, String, Object[])¶
internal static void fprintf(Stream fd, string format, Object[] list)
Parameters¶
fd
Stream
format
String
list
Object[]
isPseudoTag(TiffTag)¶
internal static bool isPseudoTag(TiffTag t)
Parameters¶
t
TiffTag
Returns¶
setString(String&, String)¶
internal static void setString(String& cpp, string cp)
Parameters¶
cpp
String&
cp
String
setShortArray(Int16[]&, Int16[], Int32)¶
internal static void setShortArray(Int16[]& wpp, Int16[] wp, int n)
Parameters¶
wpp
Int16[]&
wp
Int16[]
n
Int32
setLongArray(Int32[]&, Int32[], Int32)¶
internal static void setLongArray(Int32[]& lpp, Int32[] lp, int n)
Parameters¶
lpp
Int32[]&
lp
Int32[]
n
Int32
setLong8Array(Int64[]&, Int64[], Int32)¶
internal static void setLong8Array(Int64[]& lpp, Int64[] lp, int n)
Parameters¶
lpp
Int64[]&
lp
Int64[]
n
Int32
setFloatArray(Single[]&, Single[], Int32)¶
internal static void setFloatArray(Single[]& fpp, Single[] fp, int n)
Parameters¶
fpp
Single[]&
fp
Single[]
n
Int32
fieldSet(Int32)¶
internal bool fieldSet(int field)
Parameters¶
field
Int32
Returns¶
setFieldBit(Int32)¶
internal void setFieldBit(int field)
Parameters¶
field
Int32
clearFieldBit(Int32)¶
internal void clearFieldBit(int field)
Parameters¶
field
Int32
dataSize(TiffType)¶
internal static int dataSize(TiffType type)
Parameters¶
type
TiffType
Returns¶
roundUp(Int32, Int32)¶
internal static int roundUp(int x, int y)
Parameters¶
x
Int32
y
Int32
Returns¶
howMany(Int32, Int32)¶
internal static int howMany(int x, int y)
Parameters¶
x
Int32
y
Int32
Returns¶
howMany(UInt64, UInt64)¶
internal static ulong howMany(ulong x, ulong y)
Parameters¶
x
UInt64
y
UInt64