BitMiracle.LibTiff.NET
Regenerated line info.
Possible values for .CLEANFAXDATA tag.
No errors detected.
Receiver regenerated lines.
Uncorrected errors exist.
Color curve accuracy.
Possible values for .COLORRESPONSEUNIT tag.
Tenths of a unit.
Hundredths of a unit.
Thousandths of a unit.
Ten-thousandths of a unit.
Hundred-thousandths.
Compression scheme.
Possible values for .COMPRESSION tag.
Dump mode.
CCITT modified Huffman RLE.
CCITT Group 3 fax encoding.
CCITT T.4 (TIFF 6 name for CCITT Group 3 fax encoding).
CCITT Group 4 fax encoding.
CCITT T.6 (TIFF 6 name for CCITT Group 4 fax encoding).
Lempel-Ziv & Welch.
Original JPEG / Old-style JPEG (6.0).
JPEG DCT compression. Introduced post TIFF rev 6.0.
NeXT 2-bit RLE.
CCITT RLE.
Macintosh RLE.
ThunderScan RLE.
IT8 CT w/padding. Reserved for ANSI IT8 TIFF/IT.
IT8 Linework RLE. Reserved for ANSI IT8 TIFF/IT.
IT8 Monochrome picture. Reserved for ANSI IT8 TIFF/IT.
IT8 Binary line art. Reserved for ANSI IT8 TIFF/IT.
Pixar companded 10bit LZW. Reserved for Pixar.
Pixar companded 11bit ZIP. Reserved for Pixar.
Deflate compression.
Deflate compression, as recognized by Adobe.
Kodak DCS encoding.
Reserved for Oceana Matrix (dev@oceana.com).
ISO JBIG.
SGI Log Luminance RLE.
SGI Log 24-bit packed.
Leadtools JPEG2000.
Information about extra samples.
Possible values for .EXTRASAMPLES tag.
Unspecified data.
Associated alpha data.
Unassociated alpha data.
Group 3/4 format control.
Possible values for .FAXMODE tag.
Default, include RTC.
No RTC at end of data.
No EOL code at end of row.
Byte align row.
Word align row.
TIFF Class F.
Subfile data descriptor.
Possible values for .SUBFILETYPE tag.
Reduced resolution version.
One page of many.
Transparency mask.
Data order within a byte.
Possible values for .FILLORDER tag.
Most significant -> least.
Least significant -> most.
Gray scale curve accuracy.
Possible values for .GRAYRESPONSEUNIT tag.
Tenths of a unit.
Hundredths of a unit.
Thousandths of a unit.
Ten-thousandths of a unit.
Hundred-thousandths.
Options for CCITT Group 3/4 fax encoding.
Possible values for .GROUP3OPTIONS / TiffTag.T4OPTIONS and
TiffTag.GROUP4OPTIONS / TiffTag.T6OPTIONS tags.
Unknown (uninitialized).
2-dimensional coding.
Data not compressed.
Fill to byte boundary.
Inks in separated image.
Possible values for .INKSET tag.
Cyan-magenta-yellow-black color.
Multi-ink or hi-fi color.
Auto RGB<=>YCbCr convert.
Possible values for .JPEGCOLORMODE tag.
No conversion (default).
Do auto conversion.
JPEG processing algorithm.
Possible values for .JPEGPROC tag.
Baseline sequential.
Huffman coded lossless.
Jpeg Tables Mode.
Possible values for .JPEGTABLESMODE tag.
None.
Include quantization tables.
Include Huffman tables.
Kind of data in subfile.
Possible values for .OSUBFILETYPE tag.
Full resolution image data.
Reduced size image data.
One page of many.
Image orientation.
Possible values for .ORIENTATION tag.
Row 0 top, Column 0 lhs.
Row 0 top, Column 0 rhs.
Row 0 bottom, Column 0 rhs.
Row 0 bottom, Column 0 lhs.
Row 0 lhs, Column 0 top.
Row 0 rhs, Column 0 top.
Row 0 rhs, Column 0 bottom.
Row 0 lhs, Column 0 bottom.
Photometric interpretation.
Possible values for .PHOTOMETRIC tag.
Min value is white.
Min value is black.
RGB color model.
Color map indexed.
[obsoleted by TIFF rev. 6.0] Holdout mask.
Color separations.
CCIR 601.
1976 CIE L*a*b*.
ICC L*a*b*. Introduced post TIFF rev 6.0 by Adobe TIFF Technote 4.
ITU L*a*b*.
CIE Log2(L).
CIE Log2(L) (u',v').
Storage organization.
Possible values for .PLANARCONFIG tag.
Unknown (uninitialized).
Single image plane.
Separate planes of data.
Prediction scheme w/ LZW.
Possible values for .PREDICTOR tag.
No prediction scheme used.
Horizontal differencing.
Floating point predictor.
Units of resolutions.
Possible values for .RESOLUTIONUNIT tag.
No meaningful units.
English.
Metric.
Data sample format.
Possible values for .SAMPLEFORMAT tag.
Unsigned integer data
Signed integer data
IEEE floating point data
Untyped data
Complex signed int
Complex ieee floating
Thresholding used on data.
Possible values for .THRESHHOLDING tag.
B&W art scan.
Dithered scan.
Usually Floyd-Steinberg.
Flags that can be passed to
method to control printing of data structures that are potentially very large.
More than one flag can be used. Bit-or these flags to enable printing
multiple items.
no extra info
strips/tiles info
color/gray response curves
colormap
JPEG Q matrices
JPEG AC tables
JPEG DC tables
TIFF tag definitions.
Joris Van Damme maintains
TIFF Tag Reference, good source of tag information. It's an overview of known TIFF
Tags with properties, short description, and other useful information.
Tag placeholder
Subfile data descriptor.
For the list of possible values, see .
[obsoleted by TIFF rev. 5.0]
Kind of data in subfile. For the list of possible values, see .
Image width in pixels.
Image height in pixels.
Bits per channel (sample).
Data compression technique.
For the list of possible values, see .
Photometric interpretation.
For the list of possible values, see .
[obsoleted by TIFF rev. 5.0]
Thresholding used on data. For the list of possible values, see .
[obsoleted by TIFF rev. 5.0]
Dithering matrix width.
[obsoleted by TIFF rev. 5.0]
Dithering matrix height.
Data order within a byte.
For the list of possible values, see .
Name of document which holds for image.
Information about image.
Scanner manufacturer name.
Scanner model name/number.
Offsets to data strips.
[obsoleted by TIFF rev. 5.0]
Image orientation. For the list of possible values, see .
Samples per pixel.
Rows per strip of data.
Bytes counts for strips.
[obsoleted by TIFF rev. 5.0]
Minimum sample value.
[obsoleted by TIFF rev. 5.0]
Maximum sample value.
Pixels/resolution in x.
Pixels/resolution in y.
Storage organization.
For the list of possible values, see .
Page name image is from.
X page offset of image lhs.
Y page offset of image lhs.
[obsoleted by TIFF rev. 5.0]
Byte offset to free block.
[obsoleted by TIFF rev. 5.0]
Sizes of free blocks.
[obsoleted by TIFF rev. 6.0]
Gray scale curve accuracy.
For the list of possible values, see .
[obsoleted by TIFF rev. 6.0]
Gray scale response curve.
Options for CCITT Group 3 fax encoding. 32 flag bits.
For the list of possible values, see .
TIFF 6.0 proper name alias for GROUP3OPTIONS.
Options for CCITT Group 4 fax encoding. 32 flag bits.
For the list of possible values, see .
TIFF 6.0 proper name alias for GROUP4OPTIONS.
Units of resolutions.
For the list of possible values, see .
Page numbers of multi-page.
[obsoleted by TIFF rev. 6.0]
Color curve accuracy.
For the list of possible values, see .
Colorimetry info.
Name & release.
Creation date and time.
Creator of image.
Machine where created.
Prediction scheme w/ LZW.
For the list of possible values, see .
Image white point.
Primary chromaticities.
RGB map for pallette image.
Highlight + shadow info.
Tile width in pixels.
Tile height in pixels.
Offsets to data tiles.
Byte counts for tiles.
Lines with wrong pixel count.
Regenerated line info.
For the list of possible values, see .
Max consecutive bad lines.
Subimage descriptors.
Inks in separated image.
For the list of possible values, see .
ASCII names of inks.
Number of inks.
0% and 100% dot codes.
Separation target.
Information about extra samples.
For the list of possible values, see .
Data sample format.
For the list of possible values, see .
Variable MinSampleValue.
Variable MaxSampleValue.
ClipPath. Introduced post TIFF rev 6.0 by Adobe TIFF technote 2.
XClipPathUnits. Introduced post TIFF rev 6.0 by Adobe TIFF technote 2.
YClipPathUnits. Introduced post TIFF rev 6.0 by Adobe TIFF technote 2.
Indexed. Introduced post TIFF rev 6.0 by Adobe TIFF Technote 3.
JPEG table stream. Introduced post TIFF rev 6.0.
OPI Proxy. Introduced post TIFF rev 6.0 by Adobe TIFF technote.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
JPEG processing algorithm.
For the list of possible values, see .
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
Pointer to SOI marker.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
JFIF stream length
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
Restart interval length.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
Lossless proc predictor.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
Lossless point transform.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
Q matrice offsets.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
DCT table offsets.
[obsoleted by Technical Note #2 which specifies a revised JPEG-in-TIFF scheme]
AC coefficient offsets.
RGB -> YCbCr transform.
YCbCr subsampling factors.
Subsample positioning.
For the list of possible values, see .
Colorimetry info.
XML packet. Introduced post TIFF rev 6.0 by Adobe XMP Specification, January 2004.
OPI ImageID. Introduced post TIFF rev 6.0 by Adobe TIFF technote.
Image reference points. Private tag registered to Island Graphics.
Region-xform tack point. Private tag registered to Island Graphics.
Warp quadrilateral. Private tag registered to Island Graphics.
Affine transformation matrix. Private tag registered to Island Graphics.
[obsoleted by TIFF rev. 6.0]
Use EXTRASAMPLE tag. Private tag registered to SGI.
[obsoleted by TIFF rev. 6.0]
Use SAMPLEFORMAT tag. Private tag registered to SGI.
Z depth of image. Private tag registered to SGI.
Z depth/data tile. Private tag registered to SGI.
Full image size in X. This tag is set when an image has been cropped out of a larger
image. It reflect width of the original uncropped image. The XPOSITION tag can be used
to determine the position of the smaller image in the larger one.
Private tag registered to Pixar.
Full image size in Y. This tag is set when an image has been cropped out of a larger
image. It reflect height of the original uncropped image. The YPOSITION can be used
to determine the position of the smaller image in the larger one.
Private tag registered to Pixar.
Texture map format. Used to identify special image modes and data used by Pixar's
texture formats. Private tag registered to Pixar.
S&T wrap modes. Used to identify special image modes and data used by Pixar's
texture formats. Private tag registered to Pixar.
Cotan(fov) for env. maps. Used to identify special image modes and data used by
Pixar's texture formats. Private tag registered to Pixar.
Used to identify special image modes and data used by Pixar's texture formats.
Private tag registered to Pixar.
Used to identify special image modes and data used by Pixar's texture formats.
Private tag registered to Pixar.
Device serial number. Private tag registered to Eastman Kodak.
Copyright string. This tag is listed in the TIFF rev. 6.0 w/ unknown ownership.
IPTC TAG from RichTIFF specifications.
Site name. Reserved for ANSI IT8 TIFF/IT.
Color seq. [RGB, CMYK, etc]. Reserved for ANSI IT8 TIFF/IT.
DDES Header. Reserved for ANSI IT8 TIFF/IT.
Raster scanline padding. Reserved for ANSI IT8 TIFF/IT.
The number of bits in short run. Reserved for ANSI IT8 TIFF/IT.
The number of bits in long run. Reserved for ANSI IT8 TIFF/IT.
LW colortable. Reserved for ANSI IT8 TIFF/IT.
BP/BL image color switch. Reserved for ANSI IT8 TIFF/IT.
BP/BL bg color switch. Reserved for ANSI IT8 TIFF/IT.
BP/BL image color value. Reserved for ANSI IT8 TIFF/IT.
BP/BL bg color value. Reserved for ANSI IT8 TIFF/IT.
MP pixel intensity value. Reserved for ANSI IT8 TIFF/IT.
HC transparency switch. Reserved for ANSI IT8 TIFF/IT.
Color characterization table. Reserved for ANSI IT8 TIFF/IT.
HC usage indicator. Reserved for ANSI IT8 TIFF/IT.
Trapping indicator (untrapped = 0, trapped = 1). Reserved for ANSI IT8 TIFF/IT.
CMYK color equivalents.
Sequence Frame Count. Private tag registered to Texas Instruments.
Private tag registered to Adobe for PhotoShop.
Pointer to EXIF private directory. This tag is documented in EXIF specification.
ICC profile data. ?? Private tag registered to Adobe. ??
JBIG options. Private tag registered to Pixel Magic.
Pointer to GPS private directory. This tag is documented in EXIF specification.
Encoded Class 2 ses. params. Private tag registered to SGI.
Received SubAddr string. Private tag registered to SGI.
Receive time (secs). Private tag registered to SGI.
Encoded fax ses. params, Table 2/T.30. Private tag registered to SGI.
Sample value to Nits. Private tag registered to SGI.
Private tag registered to FedEx.
Pointer to Interoperability private directory.
This tag is documented in EXIF specification.
DNG version number. Introduced by Adobe DNG specification.
DNG compatibility version. Introduced by Adobe DNG specification.
Name for the camera model. Introduced by Adobe DNG specification.
Localized camera model name. Introduced by Adobe DNG specification.
CFAPattern->LinearRaw space mapping. Introduced by Adobe DNG specification.
Spatial layout of the CFA. Introduced by Adobe DNG specification.
Lookup table description. Introduced by Adobe DNG specification.
Repeat pattern size for the BlackLevel tag. Introduced by Adobe DNG specification.
Zero light encoding level. Introduced by Adobe DNG specification.
Zero light encoding level differences (columns). Introduced by Adobe DNG specification.
Zero light encoding level differences (rows). Introduced by Adobe DNG specification.
Fully saturated encoding level. Introduced by Adobe DNG specification.
Default scale factors. Introduced by Adobe DNG specification.
Origin of the final image area. Introduced by Adobe DNG specification.
Size of the final image area. Introduced by Adobe DNG specification.
XYZ->reference color space transformation matrix 1.
Introduced by Adobe DNG specification.
XYZ->reference color space transformation matrix 2.
Introduced by Adobe DNG specification.
Calibration matrix 1. Introduced by Adobe DNG specification.
Calibration matrix 2. Introduced by Adobe DNG specification.
Dimensionality reduction matrix 1. Introduced by Adobe DNG specification.
Dimensionality reduction matrix 2. Introduced by Adobe DNG specification.
Gain applied the stored raw values. Introduced by Adobe DNG specification.
Selected white balance in linear reference space.
Introduced by Adobe DNG specification.
Selected white balance in x-y chromaticity coordinates.
Introduced by Adobe DNG specification.
How much to move the zero point. Introduced by Adobe DNG specification.
Relative noise level. Introduced by Adobe DNG specification.
Relative amount of sharpening. Introduced by Adobe DNG specification.
How closely the values of the green pixels in the blue/green rows
track the values of the green pixels in the red/green rows.
Introduced by Adobe DNG specification.
Non-linear encoding range. Introduced by Adobe DNG specification.
Camera's serial number. Introduced by Adobe DNG specification.
Information about the lens.
Chroma blur radius. Introduced by Adobe DNG specification.
Relative strength of the camera's anti-alias filter.
Introduced by Adobe DNG specification.
Used by Adobe Camera Raw. Introduced by Adobe DNG specification.
Manufacturer's private data. Introduced by Adobe DNG specification.
Whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data.
Introduced by Adobe DNG specification.
Illuminant 1. Introduced by Adobe DNG specification.
Illuminant 2. Introduced by Adobe DNG specification.
Best quality multiplier. Introduced by Adobe DNG specification.
Unique identifier for the raw image data. Introduced by Adobe DNG specification.
File name of the original raw file. Introduced by Adobe DNG specification.
Contents of the original raw file. Introduced by Adobe DNG specification.
Active (non-masked) pixels of the sensor. Introduced by Adobe DNG specification.
List of coordinates of fully masked pixels. Introduced by Adobe DNG specification.
Used to map cameras's color space into ICC profile space.
Introduced by Adobe DNG specification.
Used to map cameras's color space into ICC profile space.
Introduced by Adobe DNG specification.
Introduced by Adobe DNG specification.
Introduced by Adobe DNG specification.
Undefined tag used by Eastman Kodak, hue shift correction data.
[pseudo tag. not written to file]
Group 3/4 format control.
For the list of possible values, see .
[pseudo tag. not written to file]
Compression quality level. Quality level is on the IJG 0-100 scale. Default value is 75.
[pseudo tag. not written to file]
Auto RGB<=>YCbCr convert.
For the list of possible values, see .
[pseudo tag. not written to file]
For the list of possible values, see .
Default is | .
[pseudo tag. not written to file]
G3/G4 fill function.
[pseudo tag. not written to file]
PixarLogCodec I/O data sz.
[pseudo tag. not written to file]
Imager mode & filter.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Interpolation mode.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Color balance values.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Color correction values.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Gamma value.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Toe & shoulder points.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
Calibration file description.
[pseudo tag. not written to file]
Compression quality level.
Quality level is on the ZLIB 1-9 scale. Default value is -1.
[pseudo tag. not written to file]
PixarLog uses same scale.
[pseudo tag. not written to file]
Area of image to acquire.
Allocated to Oceana Matrix (dev@oceana.com).
[pseudo tag. not written to file]
SGILog user data format.
[pseudo tag. not written to file]
SGILog data encoding control.
Exposure time.
F number.
Exposure program.
Spectral sensitivity.
ISO speed rating.
Optoelectric conversion factor.
Exif version.
Date and time of original data generation.
Date and time of digital data generation.
Meaning of each component.
Image compression mode.
Shutter speed.
Aperture.
Brightness.
Exposure bias.
Maximum lens aperture.
Subject distance.
Metering mode.
Light source.
Flash.
Lens focal length.
Subject area.
Manufacturer notes.
User comments.
DateTime subseconds.
DateTimeOriginal subseconds.
DateTimeDigitized subseconds.
Supported Flashpix version.
Color space information.
Valid image width.
Valid image height.
Related audio file.
Flash energy.
Spatial frequency response.
Focal plane X resolution.
Focal plane Y resolution.
Focal plane resolution unit.
Subject location.
Exposure index.
Sensing method.
File source.
Scene type.
CFA pattern.
Custom image processing.
Exposure mode.
White balance.
Digital zoom ratio.
Focal length in 35 mm film.
Scene capture type.
Gain control.
Contrast.
Saturation.
Sharpness.
Device settings description.
Subject distance range.
Unique image ID.
This tag is defining exact affine transformations between raster and model space. Used in interchangeable GeoTIFF files.
This tag stores raster->model tiepoint pairs. Used in interchangeable GeoTIFF files.
This tag is optionally provided for defining exact affine transformations between raster and model space. Used in interchangeable GeoTIFF files.
This tag may be used to store the GeoKey Directory, which defines and references the "GeoKeys". Used in interchangeable GeoTIFF files.
This tag is used to store all of the DOUBLE valued GeoKeys, referenced by the GeoKeyDirectoryTag. Used in interchangeable GeoTIFF files.
This tag is used to store all of the ASCII valued GeoKeys, referenced by the GeoKeyDirectoryTag. Used in interchangeable GeoTIFF files.
This tag is used to store the band nodata value. Used in interchangeable GeoTIFF files.
Tag data type.
Note: RATIONALs are the ratio of two 32-bit integer values.
Placeholder.
For field descriptor searching.
8-bit unsigned integer.
8-bit bytes with last byte null.
16-bit unsigned integer.
32-bit unsigned integer.
64-bit unsigned fraction.
8-bit signed integer.
8-bit untyped data.
16-bit signed integer.
32-bit signed integer.
64-bit signed fraction.
32-bit IEEE floating point.
64-bit IEEE floating point.
32-bit unsigned integer (offset)
BigTIFF 64-bit unsigned long
BigTIFF 64-bit signed long
BigTIFF 64-bit unsigned integer/long (offset)
Subsample positioning.
Possible values for .YCBCRPOSITIONING tag.
As in PostScript Level 2
As in CCIR 601-1
Field bits (flags) for tags.
Field bits used to indicate fields that have been set in a directory, and to
reference fields when manipulating a directory.
This value is used to signify tags that are to be processed
but otherwise ignored.
This permits antiquated tags to be quietly read and discarded. Note that
a bit is allocated for ignored tags; this is understood by the
directory reading logic which uses this fact to avoid special-case handling.
This value is used to signify pseudo-tags.
Pseudo-tags don't normally need field bits since they are not
written to an output file (by definition). The library also has
express logic to always query a codec for a pseudo-tag so allocating
a field bit for one is a waste. If codec wants to promote the notion
of a pseudo-tag being set or unset then it can do using
internal state flags without polluting the field bit space defined
for real tags.
This value is used to signify custom tags.
This value is used as a base (starting) value for codec-private tags.
Last usable value for field bit. All tags values should be less than this value.
Holds a value of a Tiff tag.
Simply put, it is a wrapper around System.Object, that helps to deal with
unboxing and conversion of types a bit easier.
Please take a look at:
http://blogs.msdn.com/ericlippert/archive/2009/03/19/representation-and-identity.aspx
Gets the value.
The value.
Retrieves value converted to byte.
The value converted to byte.
Retrieves value converted to short.
The value converted to short.
Retrieves value converted to ushort.
The value converted to ushort.
Retrieves value converted to int.
The value converted to int.
Retrieves value converted to uint.
The value converted to uint.
Retrieves value converted to long.
The value converted to long.
Retrieves value converted to float.
The value converted to float.
Retrieves value converted to double.
The value converted to double.
Retrieves value converted to string.
A that represents this instance.
If value is a byte array, then it gets converted to string using
Latin1 encoding encoder.
Retrieves value converted to byte array.
Value converted to byte array.
If value is byte array then it retrieved unaltered.
If value is array of short, ushort, int, uint, float or double values then this
array is converted to byte array
If value is a string then it gets converted to byte array using Latin1 encoding
encoder.
If value is of any other type then null is returned.
Retrieves value converted to array of bytes.
Value converted to array of bytes.
If value is array of bytes then it retrieved unaltered.
If value is array of short, ushort, int or uint values then each element of
field value gets converted to byte and added to resulting array.
If value is string then it gets converted to byte[] using Latin1 encoding
encoder.
If value is of any other type then null is returned.
Retrieves value converted to array of short values.
Value converted to array of short values.
If value is array of short values then it retrieved unaltered.
If value is array of bytes then each pair of bytes is converted to short and
added to resulting array. If value contains odd amount of bytes, then null is
returned.
If value is array of ushort, int or uint values then each element of field value gets
converted to short and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of ushort values.
Value converted to array of ushort values.
If value is array of ushort values then it retrieved unaltered.
If value is array of bytes then each pair of bytes is converted to ushort and
added to resulting array. If value contains odd amount of bytes, then null is
returned.
If value is array of short, int or uint values then each element of field value gets
converted to ushort and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of int values.
Value converted to array of int values.
If value is array of int values then it retrieved unaltered.
If value is array of bytes then each 4 bytes are converted to int and added to
resulting array. If value contains amount of bytes that can't be divided by 4 without
remainder, then null is returned.
If value is array of short, ushort or uint values then each element of
field value gets converted to int and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of uint values.
Value converted to array of uint values.
If value is array of uint values then it retrieved unaltered.
If value is array of bytes then each 4 bytes are converted to uint and added to
resulting array. If value contains amount of bytes that can't be divided by 4 without
remainder, then null is returned.
If value is array of short, ushort or int values then each element of
field value gets converted to uint and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of long values.
Value converted to array of long values.
If value is array of long values then it retrieved unaltered.
If value is array of bytes then each 8 bytes are converted to uint and added to
resulting array. If value contains amount of bytes that can't be divided by 8 without
remainder, then null is returned.
If value is array of short, ushort or int values then each element of
field value gets converted to long and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of float values.
Value converted to array of float values.
If value is array of float values then it retrieved unaltered.
If value is array of bytes then each 4 bytes are converted to float and added to
resulting array. If value contains amount of bytes that can't be divided by 4 without
remainder, then null is returned.
If value is array of double values then each element of field value gets
converted to float and added to resulting array.
If value is of any other type then null is returned.
Retrieves value converted to array of double values.
Value converted to array of double values.
If value is array of double values then it retrieved unaltered.
If value is array of bytes then each 8 bytes are converted to double and added to
resulting array. If value contains amount of bytes that can't be divided by 8 without
remainder, then null is returned.
If value is array of float values then each element of field value gets
converted to double and added to resulting array.
If value is of any other type then null is returned.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Setups the encoder part of the codec.
true if this codec successfully setup its encoder part and can encode data;
otherwise, false.
SetupEncode is called once before
.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Flushes any internal data buffers and terminates current operation.
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Decode the requested amount of G3 1D-encoded data.
Decode the requested amount of G3 2D-encoded data.
Encode a buffer of pixels.
Decode the requested amount of RLE-encoded data.
Decode the requested amount of G4-encoded data.
Encode the requested amount of data.
Codecs that want to support the Predictor tag should inherit from
this class instead of TiffCodec.
Such codecs should not override default TiffCodec's methods for
decode|encode setup and encoding|decoding of row|tile|strip.
Codecs with predictor support should override equivalent methods
provided by this class.
If codec wants to provide custom tag get|set|print methods, then
it should pass pointer to a object derived from TiffTagMethods
as parameter to TIFFPredictorInit
predictor tag value
sample stride over data
tile/strip row size
horizontal differencer/accumulator
Setups the decoder part of the codec.
true if this codec successfully setup its decoder part and can decode data;
otherwise, false.
SetupDecode is called once before
.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Setups the encoder part of the codec.
true if this codec successfully setup its encoder part and can encode data;
otherwise, false.
SetupEncode is called once before
.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Floating point predictor accumulation routine.
Floating point predictor differencing routine.
Decode a scanline and apply the predictor routine.
Decode a tile/strip and apply the predictor routine. Note that horizontal differencing
must be done on a row-by-row basis. The width of a "row" has already been calculated
at pre-decode time according to the strip/tile dimensions.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Encode a chunk of pixels.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Seeks the specified row in the strip being processed.
The row to seek.
true if specified row was successfully found; otherwise, false
Encode a hunk of pixels.
Decode a hunk of pixels.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Setups the decoder part of the codec.
true if this codec successfully setup its decoder part and can decode data;
otherwise, false.
SetupDecode is called once before
.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Setups the encoder part of the codec.
true if this codec successfully setup its encoder part and can encode data;
otherwise, false.
SetupEncode is called once before
.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Calculates and/or constrains a strip size.
The proposed strip size (may be zero or negative).
A strip size to use.
Calculate and/or constrains a tile size
The proposed tile width upon the call / tile width to use after the call.
The proposed tile height upon the call / tile height to use after the call.
Set encoding state at the start of a strip or tile.
Finish up at the end of a strip or tile.
Decode a chunk of pixels.
"Standard" case: returned data is not downsampled.
Decode a chunk of pixels.
Returned data is downsampled per sampling factors.
Encode a chunk of pixels.
"Standard" case: incoming data is not downsampled.
Encode a chunk of pixels.
Incoming data is expected to be downsampled per sampling factors.
LibJpeg.Net interface layer.
We handle fatal errors when they are encountered within the JPEG
library. We also direct LibJpeg.Net error and warning
messages through the appropriate LibTiff.Net handlers.
JPEG library destination data manager.
These routines direct compressed data from LibJpeg.Net into the
LibTiff.Net output buffer.
JPEG library source data manager.
These routines supply compressed data to LibJpeg.Net
Alternate destination manager for outputting to JPEGTables field.
Alternate source manager for reading from JPEGTables.
We can share all the code except for the init routine.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Encode a chunk of pixels.
Uses an open addressing double hashing (no chaining) on the prefix code/next character
combination. We do a variant of Knuth's algorithm D (vol. 3, sec. 6.4) along with
G. Knott's relatively-prime secondary probe. Here, the modular division first probe is
gives way to a faster exclusive-or manipulation. Also do block compression with an
adaptive reset, whereby the code table is cleared when the compression ratio
decreases, but after the table fills. The variable-length output codes are re-sized at
this point, and a CODE_CLEAR is generated for the decoder.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Setups the decoder part of the codec.
true if this codec successfully setup its decoder part and can decode data;
otherwise, false.
SetupDecode is called once before
.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Setups the encoder part of the codec.
true if this codec successfully setup its encoder part and can encode data;
otherwise, false.
SetupEncode is called once before
.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Initializes this instance.
Fills input buffer
true if operation succeed; otherwise, false
Skip data - used to skip over a potentially large amount of
uninteresting data (such as an APPn marker).
The number of bytes to skip.
Writers of suspendable-input applications must note that skip_input_data
is not granted the right to give a suspension return. If the skip extends
beyond the data currently in the buffer, the buffer can be marked empty so
that the next read will cause a fill_input_buffer call that can suspend.
Arranging for additional bytes to be discarded before reloading the input
buffer is the application writer's problem.
This is the default resync_to_restart method for data source
managers to use if they don't have any better approach.
An instance of
The desired
false if suspension is required.
That method assumes that no backtracking is possible.
Some data source managers may be able to back up, or may have
additional knowledge about the data which permits a more
intelligent recovery strategy; such managers would
presumably supply their own resync method.
read_restart_marker calls resync_to_restart if it finds a marker other than
the restart marker it was expecting. (This code is *not* used unless
a nonzero restart interval has been declared.) cinfo.unread_marker is
the marker code actually found (might be anything, except 0 or FF).
The desired restart marker number (0..7) is passed as a parameter.
This routine is supposed to apply whatever error recovery strategy seems
appropriate in order to position the input stream to the next data segment.
Note that cinfo.unread_marker is treated as a marker appearing before
the current data-source input point; usually it should be reset to zero
before returning.
This implementation is substantially constrained by wanting to treat the
input as a data stream; this means we can't back up. Therefore, we have
only the following actions to work with:
1. Simply discard the marker and let the entropy decoder resume at next
byte of file.
2. Read forward until we find another marker, discarding intervening
data. (In theory we could look ahead within the current bufferload,
without having to discard data if we don't find the desired marker.
This idea is not implemented here, in part because it makes behavior
dependent on buffer size and chance buffer-boundary positions.)
3. Leave the marker unread (by failing to zero cinfo.unread_marker).
This will cause the entropy decoder to process an empty data segment,
inserting dummy zeroes, and then we will reprocess the marker.
#2 is appropriate if we think the desired marker lies ahead, while #3 is
appropriate if the found marker is a future restart marker (indicating
that we have missed the desired restart marker, probably because it got
corrupted).
We apply #2 or #3 if the found marker is a restart marker no more than
two counts behind or ahead of the expected one. We also apply #2 if the
found marker is not a legal JPEG marker code (it's certainly bogus data).
If the found marker is a restart marker more than 2 counts away, we do #1
(too much risk that the marker is erroneous; with luck we will be able to
resync at some future point).
For any valid non-restart JPEG marker, we apply #3. This keeps us from
overrunning the end of a scan. An implementation limited to single-scan
files might find it better to apply #2 for markers other than EOI, since
any other marker would have to be bogus data in that case.
Terminate source - called by jpeg_finish_decompress
after all data has been read. Often a no-op.
NB: not called by jpeg_abort or jpeg_destroy; surrounding
application must deal with any cleanup that should happen even
for error exit.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encode a rectangular chunk of pixels. We break it up into row-sized pieces to insure
that encoded runs do not span rows. Otherwise, there can be problems with the decoder
if data is read, for example, by scanlines when it was encoded by strips.
CIE Lab 1976->RGB support
Size of conversion table
Conversion of Yr to r
Conversion of Yg to g
Conversion of Yb to b
Internal format of a TIFF directory entry.
bit vector of fields that are set
size of offset and bytecount arrays
is the bytecount array sorted ascending?
TIFF Image File Directories are comprised of a table of field
descriptors of the form shown below. The table is sorted in
ascending order by tag. The values associated with each entry are
disjoint and may appear anywhere in the file (so long as they are
placed on a word boundary).
If the value is 4 bytes or less, then it is placed in the offset
field to save space. If the value is less than 4 bytes, it is
left-justified in the offset field.
number of items; length in spec
byte offset to field data
size in bytes of the entry depending on the current format
if set to true then the bigtiff size will be returned.
Structure for holding information about a display device.
XYZ -> luminance matrix
Use MSB2LSB (most significant -> least) fill order
Use LSB2MSB (least significant -> most) fill order
natural bit fill order for machine
current directory must be written
data buffers setup
encoder/decoder setup done
written 1+ scanlines to file
byte swap file information
inhibit bit reversal logic
my raw data buffer; free on close
file is tile, not strip- based
need call to postencode routine
currently writing a subifd
library is doing data up-sampling
enable strip chopping support
read header only, do not process the first directory
skip reading of raw uncompressed image data
File is written in bigTiff-format.
File must not be in bigTiff-format.
magic number (defines byte order)
TIFF version number
byte offset to first directory
reperesents the size in bytes of the offsets
constant for possibly bigtiff convert
size in bytes of the header depending on the current format
if set to true then the bigtiff size will be returned.
Convert color value from the YCbCr space to CIE XYZ.
The colorspace conversion algorithm comes from the IJG v5a code;
see below for more information on how it works.
range clamping table
Tag Image File Format (TIFF)
Based on Rev 6.0 from
Client Tag extension support (from Niles Ritter).
Compression schemes statically built into the library.
NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
If a tag can have both LONG and SHORT types then the LONG must
be placed before the SHORT for writing to work properly.
NOTE: The second field (field_readcount) and third field
(field_writecount) sometimes use the values
TiffFieldInfo.Variable (-1), TiffFieldInfo.Variable2 (-3)
and TiffFieldInfo.Spp (-2). These values should be used but
would throw off the formatting of the code, so please
interpret the -1, -2 and -3 values accordingly.
Checks the directory offset against the list of already seen directory
offsets.
This is a trick to prevent IFD looping. The one can
create TIFF file with looped directory pointers. We will maintain a
list of already seen directories and check every IFD offset against
that list.
Reads IFD structure from the specified offset.
The number of fields in the directory or 0 if failed.
Fetches a contiguous directory item.
Fetches an ASCII item from the file.
Fetch a single floating point value from the offset field and
return it as a native float.
Fetches an array of BYTE or SBYTE values.
Fetch an array of SHORT or SSHORT values.
Fetches an array of ULONG values.
Fetches an array of LONG or SLONG values.
Fetches an array of LONG or SLONG values.
Fetch an array of RATIONAL or SRATIONAL values.
Fetches an array of FLOAT values.
Fetches an array of DOUBLE values.
Fetches an array of ANY values.
The actual values are returned as doubles which should be
able hold all the types. Note in particular that we assume that the
double return value vector is large enough to read in any
fundamental type. We use that vector as a buffer to read in the base
type vector and then convert it in place to double (from end to
front of course).
Fetches a tag that is not handled by special case code.
Fetches samples/pixel short values for the specified tag and verify
that all values are the same.
Fetches samples/pixel long values for the specified tag and verify
that all values are the same.
Fetches samples/pixel ANY values for the specified tag and verify
that all values are the same.
Fetches a set of offsets or lengths.
While this routine says "strips", in fact it's also used
for tiles.
Fetches and sets the RefBlackWhite tag.
Replace a single strip (tile) of uncompressed data with multiple
strips (tiles), each approximately 8Kbytes.
This is useful for dealing with large images or for
dealing with machines with a limited amount of memory.
Writes the contents of the current directory to the specified file.
call PostEncode() first, and FreeDirectory() after writing
This routine doesn't handle overwriting a directory with
auxiliary storage that's been changed.
Writes tags that are not special cased.
Setups a directory entry with either a SHORT or LONG type
according to the value.
Setups a SHORT directory entry
Setup a directory entry for an NxM table of shorts, where M is
known to be 2**bitspersample, and write the associated indirect data.
Write/copy data associated with an ASCII or opaque tag value.
Setup a directory entry of an array of SHORT or SSHORT and write
the associated indirect values.
Setup a directory entry of an array of LONG or SLONG and write the
associated indirect values.
Setup a directory entry of an array of RATIONAL or SRATIONAL and
write the associated indirect values.
Writes an array of "type" values for a specified tag (i.e. this is
a tag which is allowed to have different types, e.g. SMaxSampleType).
Internally the data values are represented as double since a double
can hold any of the TIFF tag types (yes, this should really be an abstract
type tany_t for portability). The data is converted into the specified
type in a temporary buffer and then handed off to the appropriate array
writer.
Writes a contiguous directory item.
Link the current directory into the directory chain for the file.
Support strip chopping (whether or not to convert single-strip
uncompressed images to mutiple strips of ~8Kb to reduce memory usage)
Treat extra sample as alpha (default enabled). The RGBA interface
will treat a fourth sample with no EXTRASAMPLE_ value as being
ASSOCALPHA. Many packages produce RGBA files but don't mark the
alpha properly.
Pick up YCbCr subsampling info from the JPEG data stream to support
files lacking the tag (default enabled).
name of open file
open mode (O_*)
file offset of current directory
internal rep of current directory
current scanline
current strip for read/write
current tile for read/write
# of bytes in a tile
# of bytes in a scanline
raw data buffer
# of bytes in raw data buffer
current spot in raw buffer
bytes unread from raw buffer
callback parameter
post decoding method type
tag get/set/print routines
file offset of following directory
list of offsets to already seen directories to prevent IFD looping
number of entires in offset list
number of already seen directories
file's header block
data type shift counts
data type masks
current directory (index)
current offset for read/write
current offset for writing dir
remaining subifds to write
offset for patching SubIFD link
current column (offset by row too)
sorted table of registered tags
# entries in registered tag table
cached pointer to already found tag
extra client information.
stream used for read|write|etc.
Writes custom directory. See ticket #51.
Output directory offset.
true if succeeded; otherwise, false
post decoding routine
undefined state
undefined state
Set state to appear as if a strip has just been read in.
Read the specified strip and setup for decoding.
The data buffer is expanded, as necessary, to hold the strip's data.
Read the specified tile and setup for decoding.
The data buffer is expanded, as necessary, to hold the tile's data.
Appends the data to the specified strip.
Delegate for LibTiff.Net extender method
An instance of the class.
Extender method is usually used for registering custom tags.
To setup extender method that will be called upon creation of
each instance of object please use
method.
Delegate for a method used to image decoded spans.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The array of black and white run lengths (white then black).
The zero-based offset in array at
which current row's run begins.
The zero-based offset in array at
which next row's run begins.
The width in pixels of the row.
To override the default method used to image decoded spans please set
tag with an instance of this delegate.
Fill methods can assume the array has room for at least
runs and can overwrite data in the
array as needed (e.g. to append zero runs to bring the count up to a nice multiple).
Gets the library version string.
The library version string.
Gets the version of the library's assembly.
The version of the library's assembly.
Gets the R component from ABGR value returned by
ReadRGBAImage.
The ABGR value.
The R component from ABGR value.
Gets the G component from ABGR value returned by
ReadRGBAImage.
The ABGR value.
The G component from ABGR value.
Gets the B component from ABGR value returned by
ReadRGBAImage.
The ABGR value.
The B component from ABGR value.
Gets the A component from ABGR value returned by
ReadRGBAImage.
The ABGR value.
The A component from ABGR value.
Retrieves the codec registered for the specified compression scheme.
The compression scheme.
The codec registered for the specified compression scheme or null
if there is no codec registered for the given scheme.
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 tile sizes. Codecs are identified by the associated
value of the .COMPRESSION tag.
Other compression schemes may be registered. Registered schemes can also override the
built-in versions provided by the library.
Adds specified codec to a list of registered codec.
The codec to register.
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.
Removes specified codec from a list of registered codecs.
The codec to remove from a list of registered codecs.
Checks whether library has working codec for the specific compression scheme.
The scheme to check.
true if the codec is configured and working; otherwise, false.
Retrieves an array of configured codecs, both built-in and registered by user.
An array of configured codecs.
Allocates new byte array of specified size and copies data from the existing to
the new array.
The existing array.
The number of elements in new array.
The new byte array of specified size with data from the existing array.
Allocates new array of specified size and copies data from the existing to
the new array.
Allocates new integer array of specified size and copies data from the existing to
the new array.
The existing array.
The number of elements in new array.
The new integer array of specified size with data from the existing array.
Size of the array is in elements, not bytes.
Compares specified number of elements in two arrays.
The first array to compare.
The second array to compare.
The number of elements to compare.
The difference between compared elements or 0 if all elements are equal.
Initializes new instance of class and opens a TIFF file for
reading or writing.
The name of the file to open.
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).
The new instance of class if specified file is
successfully opened; otherwise, null.
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 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, 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.
FlagDescription
- l
When creating a new file force information be written with Little-Endian
byte order (but see below).
- b
When creating a new file force information be written with Big-Endian
byte order (but see below).
- L
Force 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.
- B
Force 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.
- H
Force image data that is read or written to be treated with bits filled
in the same order as the native CPU.
- C
Enable the use of "strip chopping" when reading images that are comprised
of a single strip or tile 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.
- c
Disable the use of strip chopping when reading images.
- h
Read 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.
- 4
Create classic TIFF file
- 8
Create BigTIFF file
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
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.
Initializes new instance of class and opens a stream with TIFF data
for reading or writing.
The name for the new instance of class.
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).
Some client data. This data is passed as parameter to every
method of the object specified by the
parameter.
An instance of the class to use for
reading, writing and seeking of TIFF data.
The new instance of class if stream is successfully
opened; otherwise, null.
This method can be used to read TIFF data from sources other than file. When custom
stream class derived from 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 . It's not required to be a file name or anything
meaningful at all.
Please read remarks for method for the list of option flags that
can be specified in parameter.
Closes a previously opened TIFF file.
This method closes a file or stream that was previously opened with
or .
Any buffered data are flushed to the file/stream,
including the contents of the current directory (if modified); and all resources
are reclaimed.
Frees and releases all resources allocated by this .
Gets the number of elements in the custom tag list.
The number of elements in the custom tag list.
Retrieves the custom tag with specified index.
The zero-based index of a custom tag to retrieve.
The custom tag with specified index.
Merges given field information to existing one.
The array of objects.
The number of items to use from the array.
Retrieves field information for the specified tag.
The tag to retrieve field information for.
The tiff data type to use us additional filter.
The field information for specified tag with specified type or null if
the field information wasn't found.
Retrieves field information for the tag with specified name.
The name of the tag to retrieve field information for.
The tiff data type to use us additional filter.
The field information for specified tag with specified type or null if
the field information wasn't found.
Retrieves field information for the specified tag.
The tag to retrieve field information for.
The field information for specified tag or null if
the field information wasn't found.
Retrieves field information for the tag with specified name.
The name of the tag to retrieve field information for.
The field information for specified tag or null if
the field information wasn't found.
Gets the currently used tag methods.
The currently used tag methods.
Sets the new tag methods to use.
Tag methods.
The previously used tag methods.
Gets the extra information with specified name associated with this .
Name of the extra information to retrieve.
The extra information with specified name associated with
this or null if extra information with specified
name was not found.
Associates extra information with this .
The information to associate with this .
The name (label) of the information.
If there is already an extra information with the name specified by
it will be replaced by the information specified by
.
Flushes pending writes to an open TIFF file.
true if succeeded; otherwise, false
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.
Flushes any pending image data for the specified file to be written out.
true if succeeded; otherwise, false
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.
Gets the value(s) of a tag in an open TIFF file.
The tag.
The value(s) of a tag in an open TIFF file as array of
objects or null if there is no such tag set.
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.
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).
The tag.
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.
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.
Reads the contents of the next TIFF directory in an open TIFF file/stream and makes
it the current directory.
true if directory was successfully read; otherwise, false if an
error was encountered, or if there are no more directories to be read.
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 or
is called.
The images that have a single uncompressed strip or tile 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 .
Reads a custom directory from the arbitrary offset within file/stream.
The directory offset.
The array of objects to read from
custom directory. Standard objects are ignored.
The number of items to use from
the array.
true if a custom directory was read successfully;
otherwise, false
Reads an EXIF directory from the given offset within file/stream.
The directory offset.
true if an EXIF directory was read successfully;
otherwise, false
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 .
The size in bytes of a row of data.
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.
Calculates the size in bytes of a complete decoded and packed raster scanline.
The size in bytes of a complete decoded and packed raster scanline.
The value returned by RasterScanlineSize may be different from the
value returned by if data is stored as separate
planes ( = .SEPARATE).
Computes the number of rows for a reasonable-sized strip according to the current
settings of the ,
and tags and any compression-specific requirements.
The esimated value (may be zero).
The number of rows for a reasonable-sized strip according to the current
tag settings and compression-specific requirements.
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 tag. If there is no
any unusual requirements DefaultStripSize tries to create strips that have
approximately 8 kilobytes of uncompressed data.
Computes the number of bytes in a row-aligned strip.
The number of bytes in a row-aligned strip
StripSize returns the equivalent size for a strip of data as it would be
returned in a call to or as it would be expected in a
call to .
If the value of the field corresponding to is
larger than the recorded , then the strip size is
truncated to reflect the actual space required to hold the strip.
Computes the number of bytes in a row-aligned strip with specified number of rows.
The number of rows in a strip.
The number of bytes in a row-aligned strip with specified number of rows.
Computes the number of bytes in a raw (i.e. not decoded) strip.
The zero-based index of a strip.
The number of bytes in a raw strip.
Computes which strip contains the specified coordinates (row, plane).
The row.
The sample plane.
The number of the strip that contains the specified coordinates.
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
( = .SEPARATE).
Retrives the number of strips in the image.
The number of strips in the image.
Computes the pixel width and height of a reasonable-sized tile suitable for setting
up the and tags.
The proposed tile width upon the call / tile width to use
after the call.
The proposed tile height upon the call / tile height to use
after the call.
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.
Compute the number of bytes in a row-aligned tile.
The number of bytes in a row-aligned tile.
TileSize returns the equivalent size for a tile of data as it would be
returned in a call to or as it would be expected in a
call to .
Computes the number of bytes in a row-aligned tile with specified number of rows.
The number of rows in a tile.
The number of bytes in a row-aligned tile with specified number of rows.
Computes the number of bytes in a raw (i.e. not decoded) tile.
The zero-based index of a tile.
The number of bytes in a raw tile.
Compute the number of bytes in each row of a tile.
The number of bytes in each row of a tile.
Computes which tile contains the specified coordinates (x, y, z, plane).
The x-coordinate.
The y-coordinate.
The z-coordinate.
The sample plane.
The number of the tile that contains the specified coordinates.
A valid tile 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 tile. The parameter
is used if the image is deeper than 1 slice ( > 1).
The parameter is used only if data are organized in separate
planes ( = .SEPARATE).
Checks whether the specified (x, y, z, plane) coordinates are within the bounds of
the image.
The x-coordinate.
The y-coordinate.
The z-coordinate.
The sample plane.
true if the specified coordinates are within the bounds of the image;
otherwise, false.
The parameter is checked against the value of the
tag. The parameter is checked
against the value of the tag. The
parameter is checked against the value of the tag
(if defined). The parameter is checked against the value of
the tag if the data are organized in separate
planes.
Retrives the number of tiles in the image.
The number of tiles in the image.
Returns the custom client data associated with this .
The custom client data associated with this .
Asscociates a custom data with this .
The data to associate.
The previously associated data.
Gets the mode with which the underlying file or stream was opened.
The mode with which the underlying file or stream was opened.
Sets the new mode for the underlying file or stream.
The new mode for the underlying file or stream.
The previous mode with which the underlying file or stream was opened.
Gets the value indicating whether the image data of this has a
tiled organization.
true if the image data of this has a tiled organization or
false if the image data of this is organized in strips.
Gets the value indicating whether the image data was in a different byte-order than
the host computer.
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.
Note that , ,
and
methods already
normally perform byte swapping to local host order if needed.
Also note that and do not
perform byte swapping to local host order.
Gets the value indicating whether the image data returned through the read interface
methods is being up-sampled.
true if the data is returned up-sampled; otherwise, false.
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 tile size
routines already do this).
Gets the value indicating whether the image data is being returned in MSB-to-LSB
bit order.
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.
Gets the value indicating whether given image data was written in big-endian order.
true if given image data was written in big-endian order; otherwise, false.
Gets the tiff stream.
The tiff stream.
Gets the current row that is being read or written.
The current row that is being read or written.
The current row is updated each time a read or write is done.
Gets the zero-based index of the current directory.
The zero-based index of the current directory.
The zero-based index returned by this method is suitable for use with
the method.
Gets the number of directories in a file.
The number of directories in a file.
Retrieves the file/stream offset of the current directory.
The file/stream offset of the current directory.
Gets the current strip that is being read or written.
The current strip that is being read or written.
The current strip is updated each time a read or write is done.
Gets the current tile that is being read or written.
The current tile that is being read or written.
The current tile is updated each time a read or write is done.
Sets up the data buffer used to read raw (encoded) data from a file.
The data buffer.
The buffer size.
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.
Sets up the data buffer used to write raw (encoded) data to a file.
The data buffer.
The buffer size.
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 tile 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.
Setups the strips.
true if setup successfully; otherwise, false
Verifies that file/stream is writable and that the directory information is
setup properly.
If set to true then ability to write tiles will be verified;
otherwise, ability to write strips will be verified.
The name of the calling method.
true if file/stream is writeable and the directory information is
setup properly; otherwise, false
Releases storage associated with current directory.
Creates a new directory within file/stream.
The newly created directory will not exist on the file/stream till
, ,
or is called.
Returns an indication of whether the current directory is the last directory
in the file.
true if current directory is the last directory in the file;
otherwise, false.
Sets the directory with specified number as the current directory.
The zero-based number of the directory to set as the
current directory.
true if the specified directory was set as current successfully;
otherwise, false
SetDirectory changes the current directory and reads its contents with
.
Sets the directory at specified file/stream offset as the current directory.
The offset from the beginnig of the file/stream to the directory
to set as the current directory.
true if the directory at specified file offset was set as current
successfully; otherwise, false
SetSubDirectory acts like , 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).
Unlinks the specified directory from the directory chain.
The zero-based number of the directory to unlink.
true if directory was unlinked successfully; otherwise, false.
UnlinkDirectory does not removes directory bytes from the file/stream.
It only makes them unused.
Sets the value(s) of a tag in a TIFF file/stream open for writing.
The tag.
The tag value(s).
true if tag value(s) were set successfully; otherwise, false.
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 or
;
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.
Writes the contents of the current directory to the file and setup to create a new
subfile (page) in the same file.
true if the current directory was written successfully;
otherwise, false
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.
Writes the current state of the TIFF directory into the file to make what is currently
in the file/stream readable.
true if the current directory was rewritten successfully;
otherwise, false
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/tile 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.
Rewrites the contents of the current directory to the file and setup to create a new
subfile (page) in the same file.
true if the current directory was rewritten successfully;
otherwise, false
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.
Prints formatted description of the contents of the current directory to the
specified stream.
Prints formatted description of the contents of the current directory to the
specified stream possibly using specified print options.
The stream.
Prints formatted description of the contents of the current directory to the
specified stream using specified print (formatting) options.
The stream.
The print (formatting) options.
Reads and decodes a scanline of data from an open TIFF file/stream.
Reads and decodes a scanline of data from an open TIFF file/stream.
The buffer to place read and decoded image data to.
The zero-based index of scanline (row) to read.
true if image data were read and decoded successfully; otherwise, false
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
or
and specify correct sample plane if
image data are organized in separate planes
( = .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 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.
Reads and decodes a scanline of data from an open TIFF file/stream.
The buffer to place read and decoded image data to.
The zero-based index of scanline (row) to read.
The zero-based index of the sample plane.
true if image data were read and decoded successfully; otherwise, false
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
or specify 0 for
parameter if image data is contiguous (i.e not organized in separate planes,
= .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 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.
Reads and decodes a scanline of data from an open TIFF file/stream.
The buffer to place read and decoded image data to.
The zero-based byte offset in at which
to begin storing read and decoded bytes.
The zero-based index of scanline (row) to read.
The zero-based index of the sample plane.
true if image data were read and decoded successfully; otherwise, false
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
or specify 0 for
parameter if image data is contiguous (i.e not organized in separate planes,
= .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 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.
Encodes and writes a scanline of data to an open TIFF file/stream.
Encodes and writes a scanline of data to an open TIFF file/stream.
The buffer with image data to be encoded and written.
The zero-based index of scanline (row) to place encoded data at.
true if image data were encoded and written successfully; otherwise, false
WriteScanline encodes and writes to a file at the specified
. Applications should use
or
and specify correct sample plane
parameter if image data in a file/stream is organized in separate planes (i.e
= .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
tag is automatically increased to include the scanline (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and 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 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.
Encodes and writes a scanline of data to an open TIFF file/stream.
The buffer with image data to be encoded and written.
The zero-based index of scanline (row) to place encoded data at.
The zero-based index of the sample plane.
true if image data were encoded and written successfully; otherwise, false
WriteScanline encodes and writes to a file at the specified
and specified sample plane .
Applications may use or specify 0 for
parameter if image data in a file/stream is contiguous (i.e
not organized in separate planes,
= .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
tag is automatically increased to include the scanline (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and 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 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.
Encodes and writes a scanline of data to an open TIFF file/stream.
The buffer with image data to be encoded and written.
The zero-based byte offset in at which
to begin reading bytes.
The zero-based index of scanline (row) to place encoded data at.
The zero-based index of the sample plane.
true if image data were encoded and written successfully; otherwise, false
WriteScanline encodes and writes to a file at the specified
and specified sample plane .
Applications may use or specify 0 for
parameter if image data in a file/stream is contiguous (i.e
not organized in separate planes,
= .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
tag is automatically increased to include the scanline (except for
= .CONTIG, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and 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 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.
Reads the image and decodes it into RGBA format raster.
Reads the image and decodes it into RGBA format raster.
The raster width.
The raster height.
The raster (the buffer to place decoded image data to).
true if the image was successfully read and converted; otherwise,
false is returned if an error was encountered.
ReadRGBAImage reads a strip- or tile-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
, , , and
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
facilities.
All error messages are directed to the current error handler.
Reads the image and decodes it into RGBA format raster.
The raster width.
The raster height.
The raster (the buffer to place decoded image data to).
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.
true if the image was successfully read and converted; otherwise, false
is returned if an error was encountered and stopOnError is false.
ReadRGBAImage reads a strip- or tile-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
, , , and
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
facilities.
All error messages are directed to the current error handler.
Reads the image and decodes it into RGBA format raster using specified raster origin.
Reads the image and decodes it into RGBA format raster using specified raster origin.
The raster width.
The raster height.
The raster (the buffer to place decoded image data to).
The raster origin position.
true if the image was successfully read and converted; otherwise, false
is returned if an error was encountered.
ReadRGBAImageOriented reads a strip- or tile-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 .BOTLEFT for
the the produced result is the same as retuned by
.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The
, , , and
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
facilities.
All error messages are directed to the current error handler.
Reads the image and decodes it into RGBA format raster using specified raster origin.
The raster width.
The raster height.
The raster (the buffer to place decoded image data to).
The raster origin position.
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.
true if the image was successfully read and converted; otherwise, false
is returned if an error was encountered and stopOnError is false.
ReadRGBAImageOriented reads a strip- or tile-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 .BOTLEFT for
the the produced result is the same as retuned by
.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The
, , , and
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
facilities.
All error messages are directed to the current error handler.
Reads a whole strip of a strip-based image, decodes it and converts it to RGBA format.
The row.
The RGBA raster.
true if the strip was successfully read and converted; otherwise,
false
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
() and rowsperstrip is the maximum lines in a strip
().
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
, , , and
should be used to access individual samples. Images without
Associated Alpha matting information have a constant Alpha of 1.0 (255).
See 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 function does a
similar operation for tiled images.
ReadRGBAStrip is just a wrapper around the more general
facilities.
All error messages are directed to the current error handler.
Reads a whole tile of a tile-based image, decodes it and converts it to RGBA format.
The column.
The row.
The RGBA raster.
true if the strip was successfully read and converted; otherwise,
false
ReadRGBATile reads a single tile of a tile-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 tile () and length is the height of a tile
().
The and values are the offsets from the
top left corner of the image to the top left corner of the tile to be read. They must
be an exact multiple of the tile 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 tile. 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
, , , and
should be used to access individual samples. Images without
Associated Alpha matting information have a constant Alpha of 1.0 (255).
See 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 tile. The function does a
similar operation for stripped images.
ReadRGBATile is just a wrapper around the more general
facilities.
All error messages are directed to the current error handler.
Check the image to see if it can be converted to RGBA format.
The error message (if any) gets placed here.
true if the image can be converted to RGBA format; otherwise,
false is returned and contains the reason why it
is being rejected.
To convert the image to RGBA format please use
,
,
or
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).
Gets the name of the file or ID string for this .
The name of the file or ID string for this .
If this was created using method then
value of fileName parameter of method is returned. If this
was created using
then value of name parameter of
method is returned.
Sets the new ID string for this .
The ID string for this .
The previous file name or ID string for this .
Please note, that is an arbitrary string used as
ID for this . It's not required to be a file name or anything
meaningful at all.
Invokes the library-wide error handling methods to (normally) write an error message
to the .
An instance of the class. Can be null.
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide error handling methods to (normally) write an error message
to the .
Invokes the library-wide error handling methods to (normally) write an error message
to the .
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide error handling methods to (normally) write an error message
to the .
An instance of the class. Can be null.
The client data to be passed to error handler.
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide error handling methods to (normally) write an error message
to the and passes client data to the error handler.
Invokes the library-wide error handling methods to (normally) write an error message
to the .
The client data to be passed to error handler.
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide warning handling methods to (normally) write a warning message
to the .
An instance of the class. Can be null.
The method in which a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide warning handling methods to (normally) write a warning message
to the .
Invokes the library-wide warning handling methods to (normally) write a warning message
to the .
The method in which a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide warning handling methods to (normally) write a warning message
to the and passes client data to the warning handler.
An instance of the class. Can be null.
The client data to be passed to warning handler.
The method in which a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Invokes the library-wide warning handling methods to (normally) write a warning message
to the and passes client data to the warning handler.
Invokes the library-wide warning handling methods to (normally) write a warning message
to the and passes client data to the warning handler.
The client data to be passed to warning handler.
The method in which a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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
to override the default error and warning handler.
Sets an instance of the class as custom library-wide
error and warning handler.
An instance of the class
to set as custom library-wide error and warning handler.
Previous error handler or null if there was no error handler set.
Sets the tag extender method.
The tag extender method.
Previous tag extender method.
Extender method is called upon creation of each instance of object.
Reads and decodes a tile of data from an open TIFF file/stream.
The buffer to place read and decoded image data to.
The zero-based byte offset in at which
to begin storing read and decoded bytes.
The x-coordinate of the pixel within a tile to be read and decoded.
The y-coordinate of the pixel within a tile to be read and decoded.
The z-coordinate of the pixel within a tile to be read and decoded.
The zero-based index of the sample plane.
The number of bytes in the decoded tile or -1 if an error occurred.
The tile to read and decode is selected by the (x, y, z, plane) coordinates (i.e.
ReadTile returns the data for the tile 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 tile of data. Applications should
call the to find out the size (in bytes) of a tile buffer.
The and parameters are always used by
ReadTile. The parameter is used if the image is deeper
than 1 slice (a value of > 1). In other cases the
value of is ignored. The parameter is
used only if data are organized in separate planes
( = .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 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.
Reads a tile of data from an open TIFF file/stream, decompresses it and places
specified amount of decompressed bytes into the user supplied buffer.
The zero-based index of the tile to read.
The buffer to place decompressed tile bytes to.
The zero-based byte offset in buffer at which to begin storing
decompressed tile bytes.
The maximum number of decompressed tile bytes to be stored
to buffer.
The actual number of bytes of data that were placed in buffer or -1 if an
error was encountered.
The value of is a "raw tile number". That is, the caller
must take into account whether or not the data are organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
To read a full tile 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 tile 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 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.
Reads the undecoded contents of a tile of data from an open TIFF file/stream and places
specified amount of read bytes into the user supplied buffer.
The zero-based index of the tile to read.
The buffer to place read tile bytes to.
The zero-based byte offset in buffer at which to begin storing
read tile bytes.
The maximum number of read tile bytes to be stored to buffer.
The actual number of bytes of data that were placed in buffer or -1 if an
error was encountered.
The value of is a "raw tile number". That is, the caller
must take into account whether or not the data are organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
To read a full tile 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 tile will be read. You should be sure
you have enough space allocated for the buffer.
Encodes and writes a tile of data to an open TIFF file/stream.
Encodes and writes a tile of data to an open TIFF file/stream.
The buffer with image data to be encoded and written.
The x-coordinate of the pixel within a tile to be encoded and written.
The y-coordinate of the pixel within a tile to be encoded and written.
The z-coordinate of the pixel within a tile to be encoded and written.
The zero-based index of the sample plane.
The number of encoded and written bytes or -1 if an error occurred.
The tile to place encoded data is selected by the (x, y, z, plane) coordinates (i.e.
WriteTile writes data to the tile containing the specified coordinates.
WriteTile (potentially) encodes the data and writes
it to open file/stream. The buffer must contain an entire tile of data. Applications
should call the to find out the size (in bytes) of a tile buffer.
The and parameters are always used by
WriteTile. The parameter is used if the image is deeper
than 1 slice (a value of > 1). In other cases the
value of is ignored. The parameter is
used only if data are organized in separate planes
( = .SEPARATE). In other
cases the value of is ignored.
A correct value for the tag must be setup before
writing; WriteTile does not support automatically growing the image on
each write (as does).
Encodes and writes a tile of data to an open TIFF file/stream.
The buffer with image data to be encoded and written.
The zero-based byte offset in at which
to begin reading bytes to be encoded and written.
The x-coordinate of the pixel within a tile to be encoded and written.
The y-coordinate of the pixel within a tile to be encoded and written.
The z-coordinate of the pixel within a tile to be encoded and written.
The zero-based index of the sample plane.
The number of encoded and written bytes or -1 if an error occurred.
The tile to place encoded data is selected by the (x, y, z, plane) coordinates (i.e.
WriteTile writes data to the tile containing the specified coordinates.
WriteTile (potentially) encodes the data and writes
it to open file/stream. The buffer must contain an entire tile of data. Applications
should call the to find out the size (in bytes) of a tile buffer.
The and parameters are always used by
WriteTile. The parameter is used if the image is deeper
than 1 slice (a value of > 1). In other cases the
value of is ignored. The parameter is
used only if data are organized in separate planes
( = .SEPARATE). In other
cases the value of is ignored.
A correct value for the tag must be setup before
writing; WriteTile does not support automatically growing the image on
each write (as does).
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.
The zero-based index of the strip to read.
The buffer to place decompressed strip bytes to.
The zero-based byte offset in buffer at which to begin storing
decompressed strip bytes.
The maximum number of decompressed strip bytes to be stored
to buffer.
The actual number of bytes of data that were placed in buffer or -1 if an
error was encountered.
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
( = .SEPARATE).
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 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.
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.
The zero-based index of the strip to read.
The buffer to place read bytes to.
The zero-based byte offset in buffer at which to begin storing
read bytes.
The maximum number of read bytes to be stored to buffer.
The actual number of bytes of data that were placed in buffer or -1 if an
error was encountered.
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
( = .SEPARATE).
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.
Encodes and writes a strip of data to an open TIFF file/stream.
The zero-based index of the strip to write.
The buffer with image data to be encoded and written.
The maximum number of strip bytes to be read from
.
The number of encoded and written bytes or -1 if an error occurred.
Encodes and writes a strip of data to an open TIFF file/stream.
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
( = .SEPARATE).
automatically does this when converting an (row, plane) to
a strip index.
If there is no space for the strip, the value of
tag is automatically increased to include the strip (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and 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 tag greater
than 8.
Encodes and writes a strip of data to an open TIFF file/stream.
The zero-based index of the strip to write.
The buffer with image data to be encoded and written.
The zero-based byte offset in at which
to begin reading bytes to be encoded and written.
The maximum number of strip bytes to be read from
.
The number of encoded and written bytes or -1 if an error occurred.
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
( = .SEPARATE).
automatically does this when converting an (row, plane) to
a strip index.
If there is no space for the strip, the value of
tag is automatically increased to include the strip (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and 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 tag greater
than 8.
Writes a strip of raw data to an open TIFF file/stream.
Writes a strip of raw data to an open TIFF file/stream.
The zero-based index of the strip to write.
The buffer with raw image data to be written.
The maximum number of strip bytes to be read from
.
The number of written bytes or -1 if an error occurred.
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
( = .SEPARATE).
automatically does this when converting an (row, plane) to
a strip index.
If there is no space for the strip, the value of
tag is automatically increased to include the strip (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and tags are
similarly enlarged to reflect data written past the previous end of image.
Writes a strip of raw data to an open TIFF file/stream.
The zero-based index of the strip to write.
The buffer with raw image data to be written.
The zero-based byte offset in at which
to begin reading bytes to be written.
The maximum number of strip bytes to be read from
.
The number of written bytes or -1 if an error occurred.
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
( = .SEPARATE).
automatically does this when converting an (row, plane) to
a strip index.
If there is no space for the strip, the value of
tag is automatically increased to include the strip (except for
= .SEPARATE, where the
tag cannot be changed once the first data are
written). If the is increased, the values of
and tags are
similarly enlarged to reflect data written past the previous end of image.
Encodes and writes a tile of data to an open TIFF file/stream.
Encodes and writes a tile of data to an open TIFF file/stream.
The zero-based index of the tile to write.
The buffer with image data to be encoded and written.
The maximum number of tile bytes to be read from
.
The number of encoded and written bytes or -1 if an error occurred.
WriteEncodedTile encodes bytes of raw data from
and append the result to the end of the specified tile. Note
that the value of is a "raw tile number". That is, the caller
must take into account whether or not the data are organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
There must be space for the data. The function clamps individual writes to a tile to
the tile size, but does not (and can not) check that multiple writes to the same tile
were performed.
A correct value for the 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 tag greater
than 8.
Encodes and writes a tile of data to an open TIFF file/stream.
The zero-based index of the tile to write.
The buffer with image data to be encoded and written.
The zero-based byte offset in at which
to begin reading bytes to be encoded and written.
The maximum number of tile bytes to be read from
.
The number of encoded and written bytes or -1 if an error occurred.
WriteEncodedTile encodes bytes of raw data from
and append the result to the end of the specified tile. Note
that the value of is a "raw tile number". That is, the caller
must take into account whether or not the data are organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
There must be space for the data. The function clamps individual writes to a tile to
the tile size, but does not (and can not) check that multiple writes to the same tile
were performed.
A correct value for the 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 tag greater
than 8.
Writes a tile of raw data to an open TIFF file/stream.
Writes a tile of raw data to an open TIFF file/stream.
The zero-based index of the tile to write.
The buffer with raw image data to be written.
The maximum number of tile bytes to be read from
.
The number of written bytes or -1 if an error occurred.
WriteRawTile appends bytes of raw data to the end of
the specified tile. Note that the value of is a "raw tile
number". That is, the caller must take into account whether or not the data are
organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
There must be space for the data. The function clamps individual writes to a tile to
the tile size, but does not (and can not) check that multiple writes to the same tile
were performed.
A correct value for the tag must be setup before
writing; WriteRawTile does not support automatically growing the image on
each write (as does).
Writes a tile of raw data to an open TIFF file/stream.
The zero-based index of the tile to write.
The buffer with raw image data to be written.
The zero-based byte offset in at which
to begin reading bytes to be written.
The maximum number of tile bytes to be read from
.
The number of written bytes or -1 if an error occurred.
WriteRawTile appends bytes of raw data to the end of
the specified tile. Note that the value of is a "raw tile
number". That is, the caller must take into account whether or not the data are
organized in separate planes
( = .SEPARATE).
automatically does this when converting an (x, y, z, plane)
coordinate quadruple to a tile number.
There must be space for the data. The function clamps individual writes to a tile to
the tile size, but does not (and can not) check that multiple writes to the same tile
were performed.
A correct value for the tag must be setup before
writing; WriteRawTile does not support automatically growing the image on
each write (as does).
Sets the current write offset.
The write offset.
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.
Gets the number of bytes occupied by the item of given type.
The type.
The number of bytes occupied by the or 0 if unknown
data type is supplied.
Swaps the bytes in a single 16-bit item.
The value to swap bytes in.
Swaps the bytes in a single 32-bit item.
The value to swap bytes in.
Swaps the bytes in a single double-precision floating-point number.
The value to swap bytes in.
Swaps the bytes in specified number of values in the array of 16-bit items.
Swaps the bytes in specified number of values in the array of 16-bit items.
The array to swap bytes in.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of 16-bit items starting at
specified offset.
The array to swap bytes in.
The zero-based offset in at
which to begin swapping bytes.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of triples (24-bit items).
Swaps the bytes in specified number of values in the array of triples (24-bit items).
The array to swap bytes in.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of triples (24-bit items)
starting at specified offset.
The array to swap bytes in.
The zero-based offset in at
which to begin swapping bytes.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of 32-bit items.
Swaps the bytes in specified number of values in the array of 32-bit items.
The array to swap bytes in.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of 64-bit items.
Swaps the bytes in specified number of values in the array of 64-bit items.
The array to swap bytes in.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of 32-bit items
starting at specified offset.
The array to swap bytes in.
The zero-based offset in at
which to begin swapping bytes.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of 64-bit items
starting at specified offset.
The array to swap bytes in.
The zero-based offset in at
which to begin swapping bytes.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of double-precision
floating-point numbers.
Swaps the bytes in specified number of values in the array of double-precision
floating-point numbers.
The array to swap bytes in.
The number of items to swap bytes in.
Swaps the bytes in specified number of values in the array of double-precision
floating-point numbers starting at specified offset.
The array to swap bytes in.
The zero-based offset in at
which to begin swapping bytes.
The number of items to swap bytes in.
Replaces specified number of bytes in with the
equivalent bit-reversed bytes.
Replaces specified number of bytes in with the
equivalent bit-reversed bytes.
The buffer to replace bytes in.
The number of bytes to process.
This operation is performed with a lookup table, which can be retrieved using the
method.
Replaces specified number of bytes in with the
equivalent bit-reversed bytes starting at specified offset.
The buffer to replace bytes in.
The zero-based offset in at
which to begin processing bytes.
The number of bytes to process.
This operation is performed with a lookup table, which can be retrieved using the
method.
Retrieves a bit reversal table.
if set to true then bit reversal table will be
retrieved; otherwise, the table that do not reverse bit values will be retrieved.
The bit reversal table.
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.
Converts a byte buffer into array of 32-bit values.
The byte buffer.
The zero-based offset in at
which to begin converting bytes.
The number of bytes to convert.
The array of 32-bit values.
Converts a byte buffer into array of 64-bit values.
The byte buffer.
The zero-based offset in at
which to begin converting bytes.
The number of bytes to convert.
The array of 64-bit values.
Converts array of 64-bit values into array of bytes.
The array of 64-bit values.
The zero-based offset in at
which to begin converting bytes.
The number of 64-bit values to convert.
The byte array to store converted values at.
The zero-based offset in at
which to begin storing converted values.
Converts array of 32-bit values into array of bytes.
The array of 32-bit values.
The zero-based offset in at
which to begin converting bytes.
The number of 32-bit values to convert.
The byte array to store converted values at.
The zero-based offset in at
which to begin storing converted values.
Converts a byte buffer into array of 16-bit values.
The byte buffer.
The zero-based offset in at
which to begin converting bytes.
The number of bytes to convert.
The array of 16-bit values.
Converts array of 16-bit values into array of bytes.
The array of 16-bit values.
The zero-based offset in at
which to begin converting bytes.
The number of 16-bit values to convert.
The byte array to store converted values at.
The zero-based offset in at
which to begin storing converted values.
Base class for all codecs within the library.
A codec is a class that implements decoding, encoding, or decoding and encoding of a
compression algorithm.
The library provides a collection of builtin codecs. More codecs may be registered
through calls to the library and/or the builtin implementations may be overridden.
An instance of .
Compression scheme this codec impelements.
Codec name.
Initializes a new instance of the class.
An instance of class.
The compression scheme for the codec.
The name of the codec.
Gets a value indicating whether this codec can encode data.
true if this codec can encode data; otherwise, false.
Gets a value indicating whether this codec can decode data.
true if this codec can decode data; otherwise, false.
Initializes this instance.
true if initialized successfully
Setups the decoder part of the codec.
true if this codec successfully setup its decoder part and can decode data;
otherwise, false.
SetupDecode is called once before
.
Prepares the decoder part of the codec for a decoding.
The zero-based sample plane index.
true if this codec successfully prepared its decoder part and ready
to decode data; otherwise, false.
PreDecode is called after and before decoding.
Decodes one row of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to .
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one strip of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to .
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Decodes one tile of image data.
The buffer to place decoded image data to.
The zero-based byte offset in at
which to begin storing decoded bytes.
The number of decoded bytes that should be placed
to .
The zero-based sample plane index.
true if image data was decoded successfully; otherwise, false.
Setups the encoder part of the codec.
true if this codec successfully setup its encoder part and can encode data;
otherwise, false.
SetupEncode is called once before
.
Prepares the encoder part of the codec for a encoding.
The zero-based sample plane index.
true if this codec successfully prepared its encoder part and ready
to encode data; otherwise, false.
PreEncode is called after and before encoding.
Performs any actions after encoding required by the codec.
true if all post-encode actions succeeded; otherwise, false
PostEncode is called after encoding and can be used to release any external
resources needed during encoding.
Encodes one row of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to .
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one strip of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to .
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Encodes one tile of image data.
The buffer with image data to be encoded.
The zero-based byte offset in at
which to begin read image data.
The maximum number of encoded bytes that can be placed
to .
The zero-based sample plane index.
true if image data was encoded successfully; otherwise, false.
Flushes any internal data buffers and terminates current operation.
Seeks the specified row in the strip being processed.
The row to seek.
true if specified row was successfully found; otherwise, false
Cleanups the state of the codec.
Cleanup is called when codec is no longer needed (won't be used) and can be
used for example to restore tag methods that were substituted.
Calculates and/or constrains a strip size.
The proposed strip size (may be zero or negative).
A strip size to use.
Calculate and/or constrains a tile size
The proposed tile width upon the call / tile width to use after the call.
The proposed tile height upon the call / tile height to use after the call.
Default error handler implementation.
TiffErrorHandler provides error and warning handling methods that write an
error or a warning messages to the .
Applications that desire to capture control in the event of an error or a warning should
set their custom error and warning handler using method.
Handles an error by writing it text to the .
An instance of the class. Can be null.
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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.
Handles an error by writing it text to the .
An instance of the class. Can be null.
A client data.
The method where an error is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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. Its value and meaning is
defined by an application and not the library.
Handles a warning by writing it text to the .
An instance of the class. Can be null.
The method where a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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.
Handles a warning by writing it text to the .
An instance of the class. Can be null.
A client data.
The method where a warning is detected.
A composite format string (see Remarks).
An object array that contains zero or more objects to format.
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. Its value and meaning is
defined by an application and not the library.
Represents a TIFF field information.
TiffFieldInfo describes a field. It provides information about field name, type,
number of values etc.
marker for variable length tags
marker for SamplesPerPixel-bound tags
marker for integer variable length tags
Initializes a new instance of the class.
The tag to describe.
The number of values to read when reading field information or
one of , and .
The number of values to write when writing field information
or one of , and .
The type of the field value.
Index of the bit to use in "Set Fields Vector" when this instance
is merged into field info collection. Take a look at class.
If true, then it is permissible to set the tag's value even
after writing has commenced.
If true, then number of value elements should be passed to
method as second parameter (right after tag type AND
before value itself).
The name (description) of the tag this instance describes.
Returns a that represents this instance.
A that represents this instance.
The tag described by this instance.
Number of values to read when reading field information or
one of , and .
Number of values to write when writing field information or
one of , and .
Type of the field values.
Index of the bit to use in "Set Fields Vector" when this instance
is merged into field info collection. Take a look at class.
If true, then it is permissible to set the tag's value even after writing has commenced.
If true, then number of value elements should be passed to
method as second parameter (right after tag type AND before values itself).
The name (or description) of the tag this instance describes.
RGBA-style image support. Provides methods for decoding images into RGBA (or other) format.
TiffRgbaImage provide a high-level interface through which TIFF images may be read
into memory. Images may be strip- or tile-based and have a variety of different
characteristics: bits/sample, samples/pixel, photometric, etc. The target raster format
can be customized to a particular application's needs by installing custom methods that
manipulate image data according to application requirements.
The default usage for this class: check if an image can be processed using
, construct an instance of
TiffRgbaImage using and then read and decode an image into a
target raster using . can be called
multiple times to decode an image using different state parameters. If multiple images
are to be displayed and there is not enough space for each of the decoded rasters,
multiple instances of TiffRgbaImage can be managed and then calls can be made to
as needed to display an image.
To use the core support for reading and processing TIFF images, but write the resulting
raster data in a different format one need only override the "put methods" used to store
raster data. These methods are initially setup by to point to methods
that pack raster data in the default ABGR pixel format. Two different methods are used
according to the physical organization of the image data in the file: one for
= .CONTIG (packed samples),
and another for = .SEPARATE
(separated samples). Note that this mechanism can be used to transform the data before
storing it in the raster. For example one can convert data to colormap indices for display
on a colormap display.
To setup custom "put" method please use property for contiguously
packed samples and/or property for separated samples.
The methods of TiffRgbaImage support the most commonly encountered flavors of TIFF.
It is possible to extend this support by overriding the "get method" invoked by
to read TIFF image data. Details of doing this are a bit involved,
it is best to make a copy of an existing get method and modify it to suit the needs of an
application. To setup custom "get" method please use property.
image handle
stop on read error
data is packed/separate
type of alpha data present
image width
image height
image bits/sample
image samples/pixel
image orientation
requested orientation
image photometric interp
colormap pallete
sample mapping array
black and white map
palette image map
YCbCr conversion state
CIE L*a*b conversion state
Delegate for "put" method (the method that is called to pack pixel data in the raster)
used when converting contiguously packed samples.
An instance of the class.
The raster (the buffer to place decoded image data to).
The zero-based byte offset in at
which to begin storing decoded bytes.
The value that should be added to
after each row processed.
The x-coordinate of the first pixel in block of pixels to be decoded.
The y-coordinate of the first pixel in block of pixels to be decoded.
The block width.
The block height.
The buffer with image data.
The zero-based byte offset in at
which to begin reading image bytes.
The value that should be added to
after each row processed.
The image reading and conversion methods invoke "put" methods to copy/image/whatever
tiles of raw image data. A default set of methods is provided to convert/copy raw
image data to 8-bit packed ABGR format rasters. Applications can supply alternate
methods that unpack the data into a different format or, for example, unpack the data
and draw the unpacked raster on the display.
To setup custom "put" method for contiguously packed samples please use
property.
The is usually 0. It is greater than 0 if width of strip
being converted is greater than image width or part of the tile being converted is
outside the image (may be true for tiles on the right and bottom edge of the image).
In other words, is used to make up for any padding on
the end of each line of the buffer with image data.
The is 0 if width of tile being converted is equal to
image width and image data should not be flipped vertically. In other circumstances
is used to make up for any padding on the end of each
line of the raster and/or for flipping purposes.
Delegate for "put" method (the method that is called to pack pixel data in the raster)
used when converting separated samples.
An instance of the class.
The raster (the buffer to place decoded image data to).
The zero-based byte offset in at
which to begin storing decoded bytes.
The value that should be added to
after each row processed.
The x-coordinate of the first pixel in block of pixels to be decoded.
The y-coordinate of the first pixel in block of pixels to be decoded.
The block width.
The block height.
The buffer with image data.
The zero-based byte offset in at
which to begin reading image bytes that constitute first sample plane.
The zero-based byte offset in at
which to begin reading image bytes that constitute second sample plane.
The zero-based byte offset in at
which to begin reading image bytes that constitute third sample plane.
The zero-based byte offset in at
which to begin reading image bytes that constitute fourth sample plane.
The value that should be added to ,
, and
after each row processed.
The image reading and conversion methods invoke "put" methods to copy/image/whatever
tiles of raw image data. A default set of methods is provided to convert/copy raw
image data to 8-bit packed ABGR format rasters. Applications can supply alternate
methods that unpack the data into a different format or, for example, unpack the data
and draw the unpacked raster on the display.
To setup custom "put" method for separated samples please use
property.
The is usually 0. It is greater than 0 if width of strip
being converted is greater than image width or part of the tile being converted is
outside the image (may be true for tiles on the right and bottom edge of the image).
In other words, is used to make up for any padding on
the end of each line of the buffer with image data.
The is 0 if width of tile being converted is equal to
image width and image data should not be flipped vertically. In other circumstances
is used to make up for any padding on the end of each
line of the raster and/or for flipping purposes.
Delegate for "get" method (the method that is called to produce RGBA raster).
An instance of the class.
The raster (the buffer to place decoded image data to).
The zero-based byte offset in at which
to begin storing decoded bytes.
The raster width.
The raster height.
true if the image was successfully read and decoded; otherwise,
false.
A default set of methods is provided to read and convert/copy raw image data to 8-bit
packed ABGR format rasters. Applications can supply alternate method for this.
To setup custom "get" method please use property.
Creates new instance of the class.
The instance of the class used to retrieve
image data.
if set to true then an error will terminate the conversion; otherwise "get"
methods will continue processing data until all the possible data in the image have
been requested.
The error message (if any) gets placed here.
New instance of the class if the image specified
by can be converted to RGBA format; otherwise, null is
returned and contains the reason why it is being
rejected.
Gets a value indicating whether image data has contiguous (packed) or separated samples.
true if this image data has contiguous (packed) samples; otherwise,
false.
Gets the type of alpha data present.
The type of alpha data present.
Gets the image width.
The image width.
Gets the image height.
The image height.
Gets the image bits per sample count.
The image bits per sample count.
Gets the image samples per pixel count.
The image samples per pixel count.
Gets the image orientation.
The image orientation.
Gets or sets the requested orientation.
The requested orientation.
The method uses this value when placing converted
image data into raster buffer.
Gets the photometric interpretation of the image data.
The photometric interpretation of the image data.
Gets or sets the "get" method (the method that is called to produce RGBA raster).
The "get" method.
Gets or sets the "put" method (the method that is called to pack pixel data in the
raster) used when converting contiguously packed samples.
The "put" method used when converting contiguously packed samples.
Gets or sets the "put" method (the method that is called to pack pixel data in the
raster) used when converting separated samples.
The "put" method used when converting separated samples.
Reads the underlaying TIFF image and decodes it into RGBA format raster.
The raster (the buffer to place decoded image data to).
The zero-based byte offset in at which
to begin storing decoded bytes.
The raster width.
The raster height.
true if the image was successfully read and decoded; otherwise,
false.
GetRaster reads image into memory using current "get" () method,
storing the result in the user supplied RGBA using one of
the "put" ( or ) methods. 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 the value of property. 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 the
value of property.
Raster pixels are 8-bit packed red, green, blue, alpha samples. The
, , , and
should be used to access individual samples. Images without
Associated Alpha matting information have a constant Alpha of 1.0 (255).
GetRaster converts non-8-bit images by scaling sample values. Palette,
grayscale, bilevel, CMYK, and YCbCr images are converted to RGB transparently.
Raster pixels are returned uncorrected by any colorimetry information present in
the directory.
Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must be
either 1, 3, or 4 (i.e. SamplesPerPixel minus ExtraSamples).
Palette image colormaps that appear to be incorrectly written as 8-bit values are
automatically scaled to 16-bits.
All error messages are directed to the current error handler.
Palette images with <= 8 bits/sample are handled with a table to avoid lots of shifts
and masks. The table is setup so that put*cmaptile (below) can retrieve 8 / bitspersample
pixel values simply by indexing into the table with one number.
Greyscale images with less than 8 bits/sample are handled with a table to avoid lots
of shifts and masks. The table is setup so that put*bwtile (below) can retrieve
8 / bitspersample pixel values simply by indexing into the table with one number.
Get an tile-organized image that has
PlanarConfiguration contiguous if SamplesPerPixel > 1
or
SamplesPerPixel == 1
Get an tile-organized image that has
SamplesPerPixel > 1
PlanarConfiguration separated
We assume that all such images are RGB.
Get a strip-organized image that has
PlanarConfiguration contiguous if SamplesPerPixel > 1
or
SamplesPerPixel == 1
Get a strip-organized image with
SamplesPerPixel > 1
PlanarConfiguration separated
We assume that all such images are RGB.
Select the appropriate conversion routine for packed data.
Select the appropriate conversion routine for unpacked data.
NB: we assume that unpacked single channel data is directed to the "packed routines.
Construct any mapping table used by the associated put method.
Construct a mapping table to convert from the range of the data samples to [0, 255] -
for display. This process also handles inverting B&W images when needed.
YCbCr -> RGB conversion and packing routines.
8-bit palette => colormap/RGB
4-bit palette => colormap/RGB
2-bit palette => colormap/RGB
1-bit palette => colormap/RGB
8-bit greyscale => colormap/RGB
8-bit greyscale with alpha => colormap/RGBA
16-bit greyscale => colormap/RGB
1-bit bilevel => colormap/RGB
2-bit greyscale => colormap/RGB
4-bit greyscale => colormap/RGB
8-bit packed samples, no Map => RGB
8-bit packed samples => RGBA w/ associated alpha (known to have Map == null)
8-bit packed samples => RGBA w/ unassociated alpha (known to have Map == null)
16-bit packed samples => RGB
16-bit packed samples => RGBA w/ associated alpha (known to have Map == null)
16-bit packed samples => RGBA w/ unassociated alpha (known to have Map == null)
8-bit packed CMYKA samples w/o Map => RGBA.
NB: The conversion of CMYKA->RGBA is *very* crude.
8-bit packed CMYK samples w/o Map => RGB.
NB: The conversion of CMYK->RGB is *very* crude.
8-bit packed CIE L*a*b 1976 samples => RGB
8-bit packed YCbCr samples w/ 2,2 subsampling => RGB
8-bit packed YCbCr samples w/ 2,1 subsampling => RGB
8-bit packed YCbCr samples w/ 4,4 subsampling => RGB
8-bit packed YCbCr samples w/ 4,2 subsampling => RGB
8-bit packed YCbCr samples w/ 4,1 subsampling => RGB
8-bit packed YCbCr samples w/ no subsampling => RGB
8-bit packed YCbCr samples w/ 1,2 subsampling => RGB
8-bit unpacked samples => RGB
8-bit unpacked samples => RGBA w/ associated alpha
8-bit unpacked samples => RGBA w/ unassociated alpha
16-bit unpacked samples => RGB
16-bit unpacked samples => RGBA w/ associated alpha
16-bit unpacked samples => RGBA w/ unassociated alpha
8-bit packed YCbCr samples w/ no subsampling => RGB
8-bit packed CMYK samples w/Map => RGB
NB: The conversion of CMYK->RGB is *very* crude.
A stream used by the library for TIFF reading and writing.
Reads a sequence of bytes from the stream and advances the position within the stream
by the number of bytes read.
A client data (by default, an underlying stream).
An array of bytes. When this method returns, the
contains the specified byte array with the values between
and ( + - 1)
replaced by the bytes read from the current source.
The zero-based byte offset in at which
to begin storing the data read from the current stream.
The maximum number of bytes to be read from the current stream.
The total number of bytes read into the . This can
be less than the number of bytes requested if that many bytes are not currently
available, or zero (0) if the end of the stream has been reached.
Writes a sequence of bytes to the current stream and advances the current position
within this stream by the number of bytes written.
A client data (by default, an underlying stream).
An array of bytes. This method copies
bytes from to the current stream.
The zero-based byte offset in at which
to begin copying bytes to the current stream.
The number of bytes to be written to the current stream.
Sets the position within the current stream.
A client data (by default, an underlying stream).
A byte offset relative to the parameter.
A value of type indicating the
reference point used to obtain the new position.
The new position within the current stream.
Closes the current stream.
A client data (by default, an underlying stream).
Gets the length in bytes of the stream.
A client data (by default, an underlying stream).
The length of the stream in bytes.
Tiff tag methods.
untyped data
signed integer data
unsigned integer data
IEEE floating point data
Sets the value(s) of a tag in a TIFF file/stream open for writing.
An instance of the class.
The tag.
The tag value(s).
true if tag value(s) were set successfully; otherwise, false.
Gets the value(s) of a tag in an open TIFF file.
An instance of the class.
The tag.
The value(s) of a tag in an open TIFF file/stream as array of
objects or null if there is no such tag set.
Prints formatted description of the contents of the current directory to the
specified stream using specified print (formatting) options.
An instance of the class.
The stream to print to.
The print (formatting) options.
Install extra samples information.
The unit of density.
Unknown density
Dots/inch
Dots/cm
Bitreading state saved across MCUs
Encapsulates buffer of image samples for one color component
When provided with funny indices (see jpeg_d_main_controller for
explanation of what it is) uses them for non-linear row access.
Derived data constructed for each Huffman table
Expanded entropy decoder object for Huffman decoding.
The savable_state subrecord contains fields that change within an MCU,
but must not be updated permanently until we complete the MCU.
Initialize for a Huffman-compressed scan.
Decode one MCU's worth of Huffman-compressed coefficients, full-size blocks.
Decode one MCU's worth of Huffman-compressed coefficients, partial blocks.
MCU decoding for DC initial scan (either spectral selection,
or first pass of successive approximation).
MCU decoding for AC initial scan (either spectral selection,
or first pass of successive approximation).
MCU decoding for DC successive approximation refinement scan.
Note: we assume such scans can be multi-component,
although the spec is not very clear on the point.
Check for a restart marker and resynchronize decoder.
Returns false if must suspend.
Expand a Huffman table definition into the derived format
This routine also performs some validation checks on the table.
Expanded entropy encoder object for Huffman encoding.
Initialize for a Huffman-compressed scan.
If gather_statistics is true, we do not output anything during the scan,
just count the Huffman symbols used and generate Huffman code tables.
Encode and output one MCU's worth of Huffman-compressed coefficients.
Finish up at the end of a Huffman-compressed scan.
Trial-encode one MCU's worth of Huffman-compressed coefficients.
No data is actually output, so no suspension return is possible.
Finish up a statistics-gathering pass and create the new Huffman tables.
Encode a single block's worth of coefficients
Huffman coding optimization.
We first scan the supplied data and count the number of uses of each symbol
that is to be Huffman-coded. (This process MUST agree with the code above.)
Then we build a Huffman coding tree for the observed counts.
Symbols which are not needed at all for the particular image are not
assigned any code, which saves space in the DHT marker as well as in
the compressed data.
Only the right 24 bits of put_buffer are used; the valid bits are
left-justified in this part. At most 16 bits can be passed to emit_bits
in one call, and we never retain more than 7 bits in put_buffer
between calls, so 24 bits are sufficient.
Emit some bits; return true if successful, false if must suspend
Outputting bits to the file
Only the right 24 bits of put_buffer are used; the valid bits are
left-justified in this part. At most 16 bits can be passed to emit_bits
in one call, and we never retain more than 7 bits in put_buffer
between calls, so 24 bits are sufficient.
Emit some bits, unless we are in gather mode
Emit a restart marker and resynchronize predictions.
IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than int.
We assume that int right shift is unsigned if int right shift is,
which should be safe.
MCU encoding for DC initial scan (either spectral selection,
or first pass of successive approximation).
MCU encoding for AC initial scan (either spectral selection,
or first pass of successive approximation).
MCU encoding for DC successive approximation refinement scan.
Note: we assume such scans can be multi-component, although the spec
is not very clear on the point.
MCU encoding for AC successive approximation refinement scan.
Expand a Huffman table definition into the derived format
Compute the derived values for a Huffman table.
This routine also performs some validation checks on the table.
Generate the best Huffman code table for the given counts, fill htbl.
The JPEG standard requires that no symbol be assigned a codeword of all
one bits (so that padding bits added at the end of a compressed segment
can't look like a valid code). Because of the canonical ordering of
codewords, this just means that there must be an unused slot in the
longest codeword length category. Section K.2 of the JPEG spec suggests
reserving such a slot by pretending that symbol 256 is a valid symbol
with count 1. In theory that's not optimal; giving it count zero but
including it in the symbol set anyway should give a better Huffman code.
But the theoretically better code actually seems to come out worse in
practice, because it produces more all-ones bytes (which incur stuffed
zero bytes in the final file). In any case the difference is tiny.
The JPEG standard requires Huffman codes to be no more than 16 bits long.
If some symbols have a very small but nonzero probability, the Huffman tree
must be adjusted to meet the code length restriction. We currently use
the adjustment method suggested in JPEG section K.2. This method is *not*
optimal; it may not choose the best possible limited-length code. But
typically only very-low-frequency symbols will be given less-than-optimal
lengths, so the code is almost optimal. Experimental comparisons against
an optimal limited-length-code algorithm indicate that the difference is
microscopic --- usually less than a hundredth of a percent of total size.
So the extra complexity of an optimal algorithm doesn't seem worthwhile.
zz to natural order for 7x7 block
zz to natural order for 6x6 block
zz to natural order for 5x5 block
zz to natural order for 4x4 block
zz to natural order for 3x3 block
zz to natural order for 2x2 block
Arithmetic coding probability estimation tables
Compute a/b rounded up to next integer, ie, ceil(a/b)
Assumes a >= 0, b > 0
Compute a rounded up to next multiple of b, ie, ceil(a/b)*b
Assumes a >= 0, b > 0
Copy some rows of samples from one place to another.
num_rows rows are copied from input_array[source_row++]
to output_array[dest_row++]; these areas may overlap for duplication.
The source and destination arrays must be at least as wide as num_cols.
Colorspace conversion
Convert some rows of samples to the JPEG colorspace.
Note that we change from the application's interleaved-pixel format
to our internal noninterleaved, one-plane-per-component format.
The input buffer is therefore three times as wide as the output buffer.
A starting row offset is provided only for the output buffer. The caller
can easily adjust the passed input_buf value to accommodate any row
offset required on that side.
Initialize for RGB->YCC colorspace conversion.
RGB -> YCbCr conversion: most common case
YCbCr is defined per CCIR 601-1, except that Cb and Cr are
normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
The conversion equations to be implemented are therefore
Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
(These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
To avoid floating-point arithmetic, we represent the fractional constants
as integers scaled up by 2^16 (about 4 digits precision); we have to divide
the products by 2^16, with appropriate rounding, to get the correct answer.
For even more speed, we avoid doing any multiplications in the inner loop
by precalculating the constants times R,G,B for all possible values.
For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
for 12-bit samples it is still acceptable. It's not very reasonable for
16-bit samples, but if you want lossless storage you shouldn't be changing
colorspace anyway.
The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
in the tables to save adding them separately in the inner loop.
Convert some rows of samples to the JPEG colorspace.
This version handles RGB->grayscale conversion, which is the same
as the RGB->Y portion of RGB->YCbCr.
We assume rgb_ycc_start has been called (we only use the Y tables).
Convert some rows of samples to the JPEG colorspace.
This version handles Adobe-style CMYK->YCCK conversion,
where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
conversion as above, while passing K (black) unchanged.
We assume rgb_ycc_start has been called.
Convert some rows of samples to the JPEG colorspace.
This version handles grayscale output with no conversion.
The source can be either plain grayscale or YCC (since Y == gray).
Convert some rows of samples to the JPEG colorspace.
This version handles multi-component colorspaces without conversion.
We assume input_components == num_components.
Colorspace conversion
Module initialization routine for output colorspace conversion.
Convert some rows of samples to the output colorspace.
Note that we change from noninterleaved, one-plane-per-component format
to interleaved-pixel format. The output buffer is therefore three times
as wide as the input buffer.
A starting row offset is provided only for the input buffer. The caller
can easily adjust the passed output_buf value to accommodate any row
offset required on that side.
Initialize tables for YCbCr->RGB colorspace conversion.
Initialize tables for BG_YCC->RGB colorspace conversion.
Adobe-style YCCK->CMYK conversion.
We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
conversion as above, while passing K (black) unchanged.
We assume build_ycc_rgb_table has been called.
Convert grayscale to RGB: just duplicate the graylevel three times.
This is provided to support applications that don't want to cope
with grayscale as a separate case.
Color conversion for grayscale: just copy the data.
This also works for YCC -> grayscale conversion, in which
we just copy the Y (luminance) component and ignore chrominance.
Color conversion for CMYK -> RGB
Color conversion for YCCK -> RGB
it's just a gybrid of YCCK -> CMYK and CMYK -> RGB conversions
Color conversion for no colorspace change: just copy the data,
converting from separate-planes to interleaved representation.
Color quantization or color precision reduction
Master control module
Per-pass setup.
This is called at the beginning of each pass. We determine which
modules will be active during this pass and give them appropriate
start_pass calls.
We also set is_last_pass to indicate whether any more passes will
be required.
Special start-of-pass hook.
This is called by jpeg_write_scanlines if call_pass_startup is true.
In single-pass processing, we need this hook because we don't want to
write frame/scan headers during jpeg_start_compress; we want to let the
application write COM markers etc. between jpeg_start_compress and the
jpeg_write_scanlines loop.
In multi-pass processing, this routine is not used.
Finish up at end of pass.
Do computations that are needed before processing a JPEG scan
cinfo.comps_in_scan and cinfo.cur_comp_info[] are already set
Coefficient buffer control
Main buffer control (downsampled-data buffer)
Process some data.
This routine handles the simple pass-through mode,
where we have only a strip buffer.
Compression preprocessing (downsampling input buffer control).
For the simple (no-context-row) case, we just need to buffer one
row group's worth of pixels for the downsampling step. At the bottom of
the image, we pad to a full row group by replicating the last pixel row.
The downsampler's last output row is then replicated if needed to pad
out to a full iMCU row.
When providing context rows, we must buffer three row groups' worth of
pixels. Three row groups are physically allocated, but the row pointer
arrays are made five row groups high, with the extra pointers above and
below "wrapping around" to point to the last and first real row groups.
This allows the downsampler to access the proper context rows.
At the top and bottom of the image, we create dummy context rows by
copying the first or last real pixel row. This copying could be avoided
by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the
trouble on the compression side.
Initialize for a processing pass.
Create the wrapped-around downsampling input buffer needed for context mode.
Process some data in the simple no-context case.
Preprocessor output data is counted in "row groups". A row group
is defined to be v_samp_factor sample rows of each component.
Downsampling will produce this much data from each max_v_samp_factor
input rows.
Process some data in the context case.
Expand an image vertically from height input_rows to height output_rows,
by duplicating the bottom row.
Master control module
Per-pass setup.
This is called at the beginning of each output pass. We determine which
modules will be active during this pass and give them appropriate
start_pass calls. We also set is_dummy_pass to indicate whether this
is a "real" output pass or a dummy pass for color quantization.
(In the latter case, we will crank the pass to completion.)
Finish up at end of an output pass.
Master selection of decompression modules.
This is done once at jpeg_start_decompress time. We determine
which modules will be used and give them appropriate initialization calls.
We also initialize the decompressor input side to begin consuming data.
Since jpeg_read_header has finished, we know what is in the SOF
and (first) SOS markers. We also have all the application parameter
settings.
Allocate and fill in the sample_range_limit table.
Several decompression processes need to range-limit values to the range
0..MAXJSAMPLE; the input value may fall somewhat outside this range
due to noise introduced by quantization, roundoff error, etc. These
processes are inner loops and need to be as fast as possible. On most
machines, particularly CPUs with pipelines or instruction prefetch,
a (subscript-check-less) C table lookup
x = sample_range_limit[x];
is faster than explicit tests
if (x & 0)
x = 0;
else if (x > MAXJSAMPLE)
x = MAXJSAMPLE;
These processes all use a common table prepared by the routine below.
For most steps we can mathematically guarantee that the initial value
of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running
from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient.But for the
initial limiting step(just after the IDCT), a wildly out-of-range value
is possible if the input data is corrupt.To avoid any chance of indexing
off the end of memory and getting a bad-pointer trap, we perform the
post-IDCT limiting thus:
x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK];
where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
samples. Under normal circumstances this is more than enough range and
a correct output will be generated; with bogus input data the mask will
cause wraparound, and we will safely generate a bogus-but-in-range output.
For the post-IDCT step, we want to convert the data from signed to unsigned
representation by adding CENTERJSAMPLE at the same time that we limit it.
This is accomplished with SUBSET = CENTER - CENTERJSAMPLE.
Note that the table is allocated in near data space on PCs; it's small
enough and used often enough to justify this.
Downsampling
Do downsampling for a whole row group (all components).
In this version we simply downsample each component independently.
Downsample pixel values of a single component.
One row group is processed per call.
This version handles arbitrary integral sampling ratios, without smoothing.
Note that this version is not actually used for customary sampling ratios.
Downsample pixel values of a single component.
This version handles the special case of a full-size component,
without smoothing.
Downsample pixel values of a single component.
This version handles the common case of 2:1 horizontal and 1:1 vertical,
without smoothing.
A note about the "bias" calculations: when rounding fractional values to
integer, we do not want to always round 0.5 up to the next integer.
If we did that, we'd introduce a noticeable bias towards larger values.
Instead, this code is arranged so that 0.5 will be rounded up or down at
alternate pixel locations (a simple ordered dither pattern).
Downsample pixel values of a single component.
This version handles the standard case of 2:1 horizontal and 2:1 vertical,
without smoothing.
Downsample pixel values of a single component.
This version handles the standard case of 2:1 horizontal and 2:1 vertical,
with smoothing. One row of context is required.
Downsample pixel values of a single component.
This version handles the special case of a full-size component,
with smoothing. One row of context is required.
Expand a component horizontally from width input_cols to width output_cols,
by duplicating the rightmost samples.
Coefficient buffer control
This code applies interblock smoothing as described by section K.8
of the JPEG standard: the first 5 AC coefficients are estimated from
the DC values of a DCT block and its 8 neighboring blocks.
We apply smoothing only for progressive JPEG decoding, and only if
the coefficients it can estimate are not yet known to full precision.
Initialize for an input processing pass.
Consume input data and store it in the full-image coefficient buffer.
We read as much as one fully interleaved MCU row ("iMCU" row) per call,
ie, v_samp_factor block rows for each component in the scan.
Initialize for an output processing pass.
Decompress and return some data in the single-pass case.
Always attempts to emit one fully interleaved MCU row ("iMCU" row).
Input and output must run in lockstep since we have only a one-MCU buffer.
Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
NB: output_buf contains a plane for each component in image,
which we index according to the component's SOF position.
Decompress and return some data in the multi-pass case.
Always attempts to emit one fully interleaved MCU row ("iMCU" row).
Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
NB: output_buf contains a plane for each component in image.
Variant of decompress_data for use when doing block smoothing.
Determine whether block smoothing is applicable and safe.
We also latch the current states of the coef_bits[] entries for the
AC coefficients; otherwise, if the input side of the decompressor
advances into a new scan, we might think the coefficients are known
more accurately than they really are.
Reset within-iMCU-row counters for a new row (input side)
Main buffer control (downsampled-data buffer)
In the current system design, the main buffer need never be a full-image
buffer; any full-height buffers will be found inside the coefficient or
postprocessing controllers. Nonetheless, the main controller is not
trivial. Its responsibility is to provide context rows for upsampling/
rescaling, and doing this in an efficient fashion is a bit tricky.
Postprocessor input data is counted in "row groups". A row group
is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
sample rows of each component. (We require DCT_scaled_size values to be
chosen such that these numbers are integers. In practice DCT_scaled_size
values will likely be powers of two, so we actually have the stronger
condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)
Upsampling will typically produce max_v_samp_factor pixel rows from each
row group (times any additional scale factor that the upsampler is
applying).
The coefficient controller will deliver data to us one iMCU row at a time;
each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or
exactly min_DCT_scaled_size row groups. (This amount of data corresponds
to one row of MCUs when the image is fully interleaved.) Note that the
number of sample rows varies across components, but the number of row
groups does not. Some garbage sample rows may be included in the last iMCU
row at the bottom of the image.
Depending on the vertical scaling algorithm used, the upsampler may need
access to the sample row(s) above and below its current input row group.
The upsampler is required to set need_context_rows true at global selection
time if so. When need_context_rows is false, this controller can simply
obtain one iMCU row at a time from the coefficient controller and dole it
out as row groups to the postprocessor.
When need_context_rows is true, this controller guarantees that the buffer
passed to postprocessing contains at least one row group's worth of samples
above and below the row group(s) being processed. Note that the context
rows "above" the first passed row group appear at negative row offsets in
the passed buffer. At the top and bottom of the image, the required
context rows are manufactured by duplicating the first or last real sample
row; this avoids having special cases in the upsampling inner loops.
The amount of context is fixed at one row group just because that's a
convenient number for this controller to work with. The existing
upsamplers really only need one sample row of context. An upsampler
supporting arbitrary output rescaling might wish for more than one row
group of context when shrinking the image; tough, we don't handle that.
(This is justified by the assumption that downsizing will be handled mostly
by adjusting the DCT_scaled_size values, so that the actual scale factor at
the upsample step needn't be much less than one.)
To provide the desired context, we have to retain the last two row groups
of one iMCU row while reading in the next iMCU row. (The last row group
can't be processed until we have another row group for its below-context,
and so we have to save the next-to-last group too for its above-context.)
We could do this most simply by copying data around in our buffer, but
that'd be very slow. We can avoid copying any data by creating a rather
strange pointer structure. Here's how it works. We allocate a workspace
consisting of M+2 row groups (where M = min_DCT_scaled_size is the number
of row groups per iMCU row). We create two sets of redundant pointers to
the workspace. Labeling the physical row groups 0 to M+1, the synthesized
pointer lists look like this:
M+1 M-1
master pointer --> 0 master pointer --> 0
1 1
... ...
M-3 M-3
M-2 M
M-1 M+1
M M-2
M+1 M-1
0 0
We read alternate iMCU rows using each master pointer; thus the last two
row groups of the previous iMCU row remain un-overwritten in the workspace.
The pointer lists are set up so that the required context rows appear to
be adjacent to the proper places when we pass the pointer lists to the
upsampler.
The above pictures describe the normal state of the pointer lists.
At top and bottom of the image, we diddle the pointer lists to duplicate
the first or last sample row as necessary (this is cheaper than copying
sample rows around).
This scheme breaks down if M less than 2, ie, min_DCT_scaled_size is 1. In that
situation each iMCU row provides only one row group so the buffering logic
must be different (eg, we must read two iMCU rows before we can emit the
first row group). For now, we simply do not support providing context
rows when min_DCT_scaled_size is 1. That combination seems unlikely to
be worth providing --- if someone wants a 1/8th-size preview, they probably
want it quick and dirty, so a context-free upsampler is sufficient.
Initialize for a processing pass.
Process some data.
This handles the simple case where no context is required.
Process some data.
This handles the case where context rows must be provided.
Process some data.
Final pass of two-pass quantization: just call the postprocessor.
Source data will be the postprocessor controller's internal buffer.
Allocate space for the funny pointer lists.
This is done only once, not once per pass.
Create the funny pointer lists discussed in the comments above.
The actual workspace is already allocated (in main.buffer),
and the space for the pointer lists is allocated too.
This routine just fills in the curiously ordered lists.
This will be repeated at the beginning of each pass.
Set up the "wraparound" pointers at top and bottom of the pointer lists.
This changes the pointer list state from top-of-image to the normal state.
Change the pointer lists to duplicate the last sample row at the bottom
of the image. m_whichFunny indicates which m_funnyIndices holds the final iMCU row.
Also sets rowgroups_avail to indicate number of nondummy row groups in row.
Decompression postprocessing (color quantization buffer control)
Initialize postprocessing controller.
Initialize for a processing pass.
Process some data in the one-pass (strip buffer) case.
This is used for color precision reduction as well as one-pass quantization.
Process some data in the first pass of 2-pass quantization.
Process some data in the second pass of 2-pass quantization.
Entropy decoding
Entropy encoding
Forward DCT (also controls coefficient quantization)
A forward DCT routine is given a pointer to an input sample array and
a pointer to a work area of type DCTELEM[]; the DCT is to be performed
in-place in that buffer. Type DCTELEM is int for 8-bit samples, INT32
for 12-bit samples. (NOTE: Floating-point DCT implementations use an
array of type FAST_FLOAT, instead.)
The input data is to be fetched from the sample array starting at a
specified column. (Any row offset needed will be applied to the array
pointer before it is passed to the FDCT code.)
Note that the number of samples fetched by the FDCT routine is
DCT_h_scaled_size * DCT_v_scaled_size.
The DCT outputs are returned scaled up by a factor of 8; they therefore
have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
convention improves accuracy in integer implementations and saves some
work in floating-point ones.
Each IDCT routine has its own ideas about the best dct_table element type.
Perform forward DCT on one or more blocks of a component.
The input samples are taken from the sample_data[] array starting at
position start_row/start_col, and moving to the right for any additional
blocks. The quantized coefficients are returned in coef_blocks[].
Initialize for a processing pass.
Verify that all referenced Q-tables are present, and set up
the divisor table for each one.
In the current implementation, DCT of all components is done during
the first pass, even if only some components will be output in the
first scan. Hence all components should be examined here.
Perform the forward DCT on one block of samples.
NOTE: this code only copes with 8x8 DCTs.
A floating-point implementation of the
forward DCT (Discrete Cosine Transform).
This implementation should be more accurate than either of the integer
DCT implementations. However, it may not give the same results on all
machines because of differences in roundoff behavior. Speed will depend
on the hardware's floating point capacity.
A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
on each column. Direct algorithms are also available, but they are
much more complex and seem not to be any faster when reduced to code.
This implementation is based on Arai, Agui, and Nakajima's algorithm for
scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
Japanese, but the algorithm is described in the Pennebaker & Mitchell
JPEG textbook (see REFERENCES section in file README). The following code
is based directly on figure 4-8 in P&M.
While an 8-point DCT cannot be done in less than 11 multiplies, it is
possible to arrange the computation so that many of the multiplies are
simple scalings of the final outputs. These multiplies can then be
folded into the multiplications or divisions by the JPEG quantization
table entries. The AA&N method leaves only 5 multiplies and 29 adds
to be done in the DCT itself.
The primary disadvantage of this method is that with a fixed-point
implementation, accuracy is lost due to imprecise representation of the
scaled quantization values. However, that problem does not arise if
we use floating point arithmetic.
Perform the forward DCT on one block of samples.
NOTE: this code only copes with 8x8 DCTs.
This file contains a fast, not so accurate integer implementation of the
forward DCT (Discrete Cosine Transform).
A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
on each column. Direct algorithms are also available, but they are
much more complex and seem not to be any faster when reduced to code.
This implementation is based on Arai, Agui, and Nakajima's algorithm for
scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
Japanese, but the algorithm is described in the Pennebaker & Mitchell
JPEG textbook (see REFERENCES section in file README). The following code
is based directly on figure 4-8 in P&M.
While an 8-point DCT cannot be done in less than 11 multiplies, it is
possible to arrange the computation so that many of the multiplies are
simple scalings of the final outputs. These multiplies can then be
folded into the multiplications or divisions by the JPEG quantization
table entries. The AA&N method leaves only 5 multiplies and 29 adds
to be done in the DCT itself.
The primary disadvantage of this method is that with fixed-point math,
accuracy is lost due to imprecise representation of the scaled
quantization values. The smaller the quantization table entry, the less
precise the scaled value, so this implementation does worse with high-
quality-setting files than with low-quality ones.
Scaling decisions are generally the same as in the LL&M algorithm;
see jpeg_fdct_islow for more details. However, we choose to descale
(right shift) multiplication products as soon as they are formed,
rather than carrying additional fractional bits into subsequent additions.
This compromises accuracy slightly, but it lets us save a few shifts.
More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
everywhere except in the multiplications proper; this saves a good deal
of work on 16-bit-int machines.
Again to save a few shifts, the intermediate results between pass 1 and
pass 2 are not upscaled, but are represented only to integral precision.
A final compromise is to represent the multiplicative constants to only
8 fractional bits, rather than 13. This saves some shifting work on some
machines, and may also reduce the cost of multiplication (since there
are fewer one-bits in the constants).
Perform the forward DCT on one block of samples.
NOTE: this code only copes with 8x8 DCTs.
A slow-but-accurate integer implementation of the
forward DCT (Discrete Cosine Transform).
A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
on each column. Direct algorithms are also available, but they are
much more complex and seem not to be any faster when reduced to code.
This implementation is based on an algorithm described in
C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
The primary algorithm described there uses 11 multiplies and 29 adds.
We use their alternate method with 12 multiplies and 32 adds.
The advantage of this method is that no data path contains more than one
multiplication; this allows a very simple and accurate implementation in
scaled fixed-point arithmetic, with a minimal number of shifts.
The poop on this scaling stuff is as follows:
Each 1-D DCT step produces outputs which are a factor of sqrt(N)
larger than the true DCT outputs. The final outputs are therefore
a factor of N larger than desired; since N=8 this can be cured by
a simple right shift at the end of the algorithm. The advantage of
this arrangement is that we save two multiplications per 1-D DCT,
because the y0 and y4 outputs need not be divided by sqrt(N).
In the IJG code, this factor of 8 is removed by the quantization
step, NOT here.
We have to do addition and subtraction of the integer inputs, which
is no problem, and multiplication by fractional constants, which is
a problem to do in integer arithmetic. We multiply all the constants
by CONST_SCALE and convert them to integer constants (thus retaining
SLOW_INTEGER_CONST_BITS bits of precision in the constants). After doing a
multiplication we have to divide the product by CONST_SCALE, with proper
rounding, to produce the correct output. This division can be done
cheaply as a right shift of SLOW_INTEGER_CONST_BITS bits. We postpone shifting
as long as possible so that partial sums can be added together with
full fractional precision.
The outputs of the first pass are scaled up by SLOW_INTEGER_PASS1_BITS bits so that
they are represented to better-than-integral precision. These outputs
require BITS_IN_JSAMPLE + SLOW_INTEGER_PASS1_BITS + 3 bits; this fits in a 16-bit word
with the recommended scaling. (For 12-bit sample data, the intermediate
array is int anyway.)
To avoid overflow of the 32-bit intermediate results in pass 2, we must
have BITS_IN_JSAMPLE + SLOW_INTEGER_CONST_BITS + SLOW_INTEGER_PASS1_BITS <= 26. Error analysis
shows that the values given below are the most effective.
Multiply a DCTELEM variable by an int constant, and immediately
descale to yield a DCTELEM result.
Input control module
Initialize the input controller module.
This is called only once, when the decompression object is created.
Reset state to begin a fresh datastream.
Initialize the input modules to read a scan of compressed data.
The first call to this is done after initializing
the entire decompressor (during jpeg_start_decompress).
Subsequent calls come from consume_markers, below.
Finish up after inputting a compressed-data scan.
This is called by the coefficient controller after it's read all
the expected data of the scan.
Read JPEG markers before, between, or after compressed-data scans.
Change state as necessary when a new scan is reached.
Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
The consume_input method pointer points either here or to the
coefficient controller's consume_data routine, depending on whether
we are reading a compressed data segment or inter-segment markers.
Note: This function should NOT return a pseudo SOS marker(with zero
component number) to the caller.A pseudo marker received by
read_markers is processed and then skipped for other markers.
Routines to calculate various quantities related to the size of the image.
Called once, when first SOS marker is reached
Save away a copy of the Q-table referenced by each component present
in the current scan, unless already saved during a prior scan.
In a multiple-scan JPEG file, the encoder could assign different components
the same Q-table slot number, but change table definitions between scans
so that each component uses a different Q-table. (The IJG encoder is not
currently capable of doing this, but other encoders might.) Since we want
to be able to dequantize all the components at the end of the file, this
means that we have to save away the table actually used for each component.
We do this by copying the table at the start of the first scan containing
the component.
The JPEG spec prohibits the encoder from changing the contents of a Q-table
slot between scans of a component using that slot. If the encoder does so
anyway, this decoder will simply use the Q-table values that were current
at the start of the first scan for the component.
The decompressor output side looks only at the saved quant tables,
not at the current Q-table slots.
Do computations that are needed before processing a JPEG scan
cinfo.comps_in_scan and cinfo.cur_comp_info[] were set from SOS marker
An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
to an output sample array. The routine must dequantize the input data as
well as perform the IDCT; for dequantization, it uses the multiplier table
pointed to by componentInfo.dct_table. The output data is to be placed into the
sample array starting at a specified column. (Any row offset needed will
be applied to the array pointer before it is passed to the IDCT code)
Note that the number of samples emitted by the IDCT routine is
DCT_h_scaled_size * DCT_v_scaled_size.
Each IDCT routine has its own ideas about the best dct_table element type.
The decompressor input side saves away the appropriate
quantization table for each component at the start of the first scan
involving that component. (This is necessary in order to correctly
decode files that reuse Q-table slots.)
When we are ready to make an output pass, the saved Q-table is converted
to a multiplier table that will actually be used by the IDCT routine.
The multiplier table contents are IDCT-method-dependent. To support
application changes in IDCT method between scans, we can remake the
multiplier tables if necessary.
In buffered-image mode, the first output pass may occur before any data
has been seen for some components, and thus before their Q-tables have
been saved away. To handle this case, multiplier tables are preset
to zeroes; the result of the IDCT will be a neutral gray level.
Prepare for an output pass.
Here we select the proper IDCT routine for each component and build
a matching multiplier table.
Perform dequantization and inverse DCT on one block of coefficients.
NOTE: this code only copes with 8x8 DCTs.
A slow-but-accurate integer implementation of the
inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
must also perform dequantization of the input coefficients.
A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
on each row (or vice versa, but it's more convenient to emit a row at
a time). Direct algorithms are also available, but they are much more
complex and seem not to be any faster when reduced to code.
This implementation is based on an algorithm described in
C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
The primary algorithm described there uses 11 multiplies and 29 adds.
We use their alternate method with 12 multiplies and 32 adds.
The advantage of this method is that no data path contains more than one
multiplication; this allows a very simple and accurate implementation in
scaled fixed-point arithmetic, with a minimal number of shifts.
The poop on this scaling stuff is as follows:
Each 1-D IDCT step produces outputs which are a factor of sqrt(N)
larger than the true IDCT outputs. The final outputs are therefore
a factor of N larger than desired; since N=8 this can be cured by
a simple right shift at the end of the algorithm. The advantage of
this arrangement is that we save two multiplications per 1-D IDCT,
because the y0 and y4 inputs need not be divided by sqrt(N).
We have to do addition and subtraction of the integer inputs, which
is no problem, and multiplication by fractional constants, which is
a problem to do in integer arithmetic. We multiply all the constants
by CONST_SCALE and convert them to integer constants (thus retaining
SLOW_INTEGER_CONST_BITS bits of precision in the constants). After doing a
multiplication we have to divide the product by CONST_SCALE, with proper
rounding, to produce the correct output. This division can be done
cheaply as a right shift of SLOW_INTEGER_CONST_BITS bits. We postpone shifting
as long as possible so that partial sums can be added together with
full fractional precision.
The outputs of the first pass are scaled up by SLOW_INTEGER_PASS1_BITS bits so that
they are represented to better-than-integral precision. These outputs
require BITS_IN_JSAMPLE + SLOW_INTEGER_PASS1_BITS + 3 bits; this fits in a 16-bit word
with the recommended scaling. (To scale up 12-bit sample data further, an
intermediate int array would be needed.)
To avoid overflow of the 32-bit intermediate results in pass 2, we must
have BITS_IN_JSAMPLE + SLOW_INTEGER_CONST_BITS + SLOW_INTEGER_PASS1_BITS <= 26. Error analysis
shows that the values given below are the most effective.
Perform dequantization and inverse DCT on one block of coefficients.
NOTE: this code only copes with 8x8 DCTs.
A fast, not so accurate integer implementation of the
inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
must also perform dequantization of the input coefficients.
A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
on each row (or vice versa, but it's more convenient to emit a row at
a time). Direct algorithms are also available, but they are much more
complex and seem not to be any faster when reduced to code.
This implementation is based on Arai, Agui, and Nakajima's algorithm for
scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
Japanese, but the algorithm is described in the Pennebaker & Mitchell
JPEG textbook (see REFERENCES section in file README). The following code
is based directly on figure 4-8 in P&M.
While an 8-point DCT cannot be done in less than 11 multiplies, it is
possible to arrange the computation so that many of the multiplies are
simple scalings of the final outputs. These multiplies can then be
folded into the multiplications or divisions by the JPEG quantization
table entries. The AA&N method leaves only 5 multiplies and 29 adds
to be done in the DCT itself.
The primary disadvantage of this method is that with fixed-point math,
accuracy is lost due to imprecise representation of the scaled
quantization values. The smaller the quantization table entry, the less
precise the scaled value, so this implementation does worse with high-
quality-setting files than with low-quality ones.
Scaling decisions are generally the same as in the LL&M algorithm;
However, we choose to descale
(right shift) multiplication products as soon as they are formed,
rather than carrying additional fractional bits into subsequent additions.
This compromises accuracy slightly, but it lets us save a few shifts.
More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
everywhere except in the multiplications proper; this saves a good deal
of work on 16-bit-int machines.
The dequantized coefficients are not integers because the AA&N scaling
factors have been incorporated. We represent them scaled up by FAST_INTEGER_PASS1_BITS,
so that the first and second IDCT rounds have the same input scaling.
For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = FAST_INTEGER_PASS1_BITS so as to
avoid a descaling shift; this compromises accuracy rather drastically
for small quantization table entries, but it saves a lot of shifts.
For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,
so we use a much larger scaling factor to preserve accuracy.
A final compromise is to represent the multiplicative constants to only
8 fractional bits, rather than 13. This saves some shifting work on some
machines, and may also reduce the cost of multiplication (since there
are fewer one-bits in the constants).
Multiply a DCTELEM variable by an int constant, and immediately
descale to yield a DCTELEM result.
Dequantize a coefficient by multiplying it by the multiplier-table
entry; produce a DCTELEM result. For 8-bit data a 16x16->16
multiplication will do. For 12-bit data, the multiplier table is
declared int, so a 32-bit multiply will be used.
Like DESCALE, but applies to a DCTELEM and produces an int.
We assume that int right shift is unsigned if int right shift is.
Perform dequantization and inverse DCT on one block of coefficients.
NOTE: this code only copes with 8x8 DCTs.
A floating-point implementation of the
inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
must also perform dequantization of the input coefficients.
This implementation should be more accurate than either of the integer
IDCT implementations. However, it may not give the same results on all
machines because of differences in roundoff behavior. Speed will depend
on the hardware's floating point capacity.
A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
on each row (or vice versa, but it's more convenient to emit a row at
a time). Direct algorithms are also available, but they are much more
complex and seem not to be any faster when reduced to code.
This implementation is based on Arai, Agui, and Nakajima's algorithm for
scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
Japanese, but the algorithm is described in the Pennebaker & Mitchell
JPEG textbook (see REFERENCES section in file README). The following code
is based directly on figure 4-8 in P&M.
While an 8-point DCT cannot be done in less than 11 multiplies, it is
possible to arrange the computation so that many of the multiplies are
simple scalings of the final outputs. These multiplies can then be
folded into the multiplications or divisions by the JPEG quantization
table entries. The AA&N method leaves only 5 multiplies and 29 adds
to be done in the DCT itself.
The primary disadvantage of this method is that with a fixed-point
implementation, accuracy is lost due to imprecise representation of the
scaled quantization values. However, that problem does not arise if
we use floating point arithmetic.
Dequantize a coefficient by multiplying it by the multiplier-table
entry; produce a float result.
Inverse-DCT routines that produce reduced-size output:
either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.
NOTE: this code only copes with 8x8 DCTs.
The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)
algorithm. We simply replace each 8-to-8 1-D IDCT step
with an 8-to-4 step that produces the four averages of two adjacent outputs
(or an 8-to-2 step producing two averages of four outputs, for 2x2 output).
These steps were derived by computing the corresponding values at the end
of the normal LL&M code, then simplifying as much as possible.
1x1 is trivial: just take the DC coefficient divided by 8.
Perform dequantization and inverse DCT on one block of coefficients,
producing a reduced-size 4x4 output block.
Perform dequantization and inverse DCT on one block of coefficients,
producing a reduced-size 2x2 output block.
Perform dequantization and inverse DCT on one block of coefficients,
producing a reduced-size 1x1 output block.
Dequantize a coefficient by multiplying it by the multiplier-table
entry; produce an int result. In this module, both inputs and result
are 16 bits or less, so either int or short multiply will work.
Marker reading and parsing
Initialize the marker reader module.
This is called only once, when the decompression object is created.
Reset marker processing state to begin a fresh datastream.
Read markers until SOS or EOI.
Returns same codes as are defined for jpeg_consume_input:
JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
Note: This function may return a pseudo SOS marker(with zero
component number) for treat by input controller's consume_input.
consume_input itself should filter out (skip) the pseudo marker
after processing for the caller.
Read a restart marker, which is expected to appear next in the datastream;
if the marker is not there, take appropriate recovery action.
Returns false if suspension is required.
Made public for use by entropy decoder only
This is called by the entropy decoder after it has read an appropriate
number of MCUs. cinfo.unread_marker may be nonzero if the entropy decoder
has already read a marker from the data source. Under normal conditions
cinfo.unread_marker will be reset to 0 before returning; if not reset,
it holds a marker which the decoder will be unable to read past.
Find the next JPEG marker, save it in cinfo.unread_marker.
Returns false if had to suspend before reaching a marker;
in that case cinfo.unread_marker is unchanged.
Note that the result might not be a valid marker code,
but it will never be 0 or FF.
Install a special processing method for COM or APPn markers.
Save an APPn or COM marker into the marker list
Skip over an unknown or uninteresting variable-length marker
Process an APP0 or APP14 marker without saving it
Examine first few bytes from an APP0.
Take appropriate action if it is a JFIF marker.
datalen is # of bytes at data[], remaining is length of rest of marker data.
Examine first few bytes from an APP14.
Take appropriate action if it is an Adobe marker.
datalen is # of bytes at data[], remaining is length of rest of marker data.
Process an SOI marker
Process a SOFn marker
Process a SOS marker
Process a DAC marker
Process a DHT marker
Process a DQT marker
Process a DRI marker
Process an LSE marker
Like next_marker, but used to obtain the initial SOI marker.
For this marker, we do not allow preceding garbage or fill; otherwise,
we might well scan an entire input file before realizing it ain't JPEG.
If an application wants to process non-JFIF files, it must seek to the
SOI before calling the JPEG library.
Marker writing
Write datastream header.
This consists of an SOI and optional APPn markers.
We recommend use of the JFIF marker, but not the Adobe marker,
when using YCbCr or grayscale data. The JFIF marker is also used
for other standard JPEG colorspaces. The Adobe marker is helpful
to distinguish RGB, CMYK, and YCCK colorspaces.
Note that an application can write additional header markers after
jpeg_start_compress returns.
Write frame header.
This consists of DQT and SOFn markers,
a conditional LSE marker and a conditional pseudo SOS marker.
Note that we do not emit the SOF until we have emitted the DQT(s).
This avoids compatibility problems with incorrect implementations that
try to error-check the quant table numbers as soon as they see the SOF.
Write scan header.
This consists of DHT or DAC markers, optional DRI, and SOS.
Compressed data will be written following the SOS.
Write datastream trailer.
Write an abbreviated table-specification datastream.
This consists of SOI, DQT and DHT tables, and EOI.
Any table that is defined and not marked sent_table = true will be
emitted. Note that all tables will be marked sent_table = true at exit.
Emit an arbitrary marker header
Emit one byte of marker parameters following write_marker_header
Emit a SOS marker
Emit an LSE inverse color transform specification marker
Emit a SOF marker
Emit an Adobe APP14 marker
Emit a DRI marker
Emit a DHT marker
Emit a DQT marker
The index.
the precision used (0 = 8bits, 1 = 16bits) for baseline checking
Emit a pseudo SOS marker
Emit a JFIF-compliant APP0 marker
Emit a marker code
Emit a 2-byte integer; these are always MSB first in JPEG files
Emit a byte
The script for encoding a multiple-scan file is an array of these:
Upsampling (note that upsampler must also call color converter)
Operating modes for buffer controllers
The main purpose of 1-pass quantization is to provide a fast, if not very
high quality, colormapped output capability. A 2-pass quantizer usually
gives better visual quality; however, for quantized grayscale output this
quantizer is perfectly adequate. Dithering is highly recommended with this
quantizer, though you can turn it off if you really want to.
In 1-pass quantization the colormap must be chosen in advance of seeing the
image. We use a map consisting of all combinations of Ncolors[i] color
values for the i'th component. The Ncolors[] values are chosen so that
their product, the total number of colors, is no more than that requested.
(In most cases, the product will be somewhat less.)
Since the colormap is orthogonal, the representative value for each color
component can be determined without considering the other components;
then these indexes can be combined into a colormap index by a standard
N-dimensional-array-subscript calculation. Most of the arithmetic involved
can be precalculated and stored in the lookup table colorindex[].
colorindex[i][j] maps pixel value j in component i to the nearest
representative value (grid plane) for that component; this index is
multiplied by the array stride for component i, so that the
index of the colormap entry closest to a given pixel value is just
sum( colorindex[component-number][pixel-component-value] )
Aside from being fast, this scheme allows for variable spacing between
representative values with no additional lookup cost.
If gamma correction has been applied in color conversion, it might be wise
to adjust the color grid spacing so that the representative colors are
equidistant in linear space. At this writing, gamma correction is not
implemented, so nothing is done here.
Declarations for Floyd-Steinberg dithering.
Errors are accumulated into the array fserrors[], at a resolution of
1/16th of a pixel count. The error at a given pixel is propagated
to its not-yet-processed neighbors using the standard F-S fractions,
... (here) 7/16
3/16 5/16 1/16
We work left-to-right on even rows, right-to-left on odd rows.
We can get away with a single array (holding one row's worth of errors)
by using it to store the current row's errors at pixel columns not yet
processed, but the next row's errors at columns already processed. We
need only a few extra variables to hold the errors immediately around the
current column. (If we are lucky, those variables are in registers, but
even if not, they're probably cheaper to access than array elements are.)
The fserrors[] array is indexed [component#][position].
We provide (#columns + 2) entries per component; the extra entry at each
end saves us from special-casing the first and last pixels.
Declarations for ordered dithering.
We use a standard 16x16 ordered dither array. The basic concept of ordered
dithering is described in many references, for instance Dale Schumacher's
chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991).
In place of Schumacher's comparisons against a "threshold" value, we add a
"dither" value to the input pixel and then round the result to the nearest
output value. The dither value is equivalent to (0.5 - threshold) times
the distance between output values. For ordered dithering, we assume that
the output colors are equally spaced; if not, results will probably be
worse, since the dither may be too much or too little at a given point.
The normal calculation would be to form pixel value + dither, range-limit
this to 0..MAXJSAMPLE, and then index into the colorindex table as usual.
We can skip the separate range-limiting step by extending the colorindex
table in both directions.
Module initialization routine for 1-pass color quantization.
The cinfo.
Initialize for one-pass color quantization.
Finish up at the end of the pass.
Switch to a new external colormap between output passes.
Shouldn't get to this!
Map some rows of pixels to the output colormapped representation.
General case, no dithering.
Map some rows of pixels to the output colormapped representation.
Fast path for out_color_components==3, no dithering
Map some rows of pixels to the output colormapped representation.
General case, with ordered dithering.
Map some rows of pixels to the output colormapped representation.
Fast path for out_color_components==3, with ordered dithering
Map some rows of pixels to the output colormapped representation.
General case, with Floyd-Steinberg dithering
Create the colormap.
Create the color index table.
Create the ordered-dither tables.
Components having the same number of representative colors may
share a dither table.
Allocate workspace for Floyd-Steinberg errors.
Return largest input value that should map to j'th output value
Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE
Return j'th output value, where j will range from 0 to maxj
The output values must fall in 0..MAXJSAMPLE in increasing order
Determine allocation of desired colors to components,
and fill in Ncolors[] array to indicate choice.
Return value is total number of colors (product of Ncolors[] values).
Create an ordered-dither array for a component having ncolors
distinct output values.
This module implements the well-known Heckbert paradigm for color
quantization. Most of the ideas used here can be traced back to
Heckbert's seminal paper
Heckbert, Paul. "Color Image Quantization for Frame Buffer Display",
Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304.
In the first pass over the image, we accumulate a histogram showing the
usage count of each possible color. To keep the histogram to a reasonable
size, we reduce the precision of the input; typical practice is to retain
5 or 6 bits per color, so that 8 or 4 different input values are counted
in the same histogram cell.
Next, the color-selection step begins with a box representing the whole
color space, and repeatedly splits the "largest" remaining box until we
have as many boxes as desired colors. Then the mean color in each
remaining box becomes one of the possible output colors.
The second pass over the image maps each input pixel to the closest output
color (optionally after applying a Floyd-Steinberg dithering correction).
This mapping is logically trivial, but making it go fast enough requires
considerable care.
Heckbert-style quantizers vary a good deal in their policies for choosing
the "largest" box and deciding where to cut it. The particular policies
used here have proved out well in experimental comparisons, but better ones
may yet be found.
In earlier versions of the IJG code, this module quantized in YCbCr color
space, processing the raw upsampled data without a color conversion step.
This allowed the color conversion math to be done only once per colormap
entry, not once per pixel. However, that optimization precluded other
useful optimizations (such as merging color conversion with upsampling)
and it also interfered with desired capabilities such as quantizing to an
externally-supplied colormap. We have therefore abandoned that approach.
The present code works in the post-conversion color space, typically RGB.
To improve the visual quality of the results, we actually work in scaled
RGB space, giving G distances more weight than R, and R in turn more than
B. To do everything in integer math, we must use integer scale factors.
The 2/3/1 scale factors used here correspond loosely to the relative
weights of the colors in the NTSC grayscale equation.
If you want to use this code to quantize a non-RGB color space, you'll
probably need to change these scale factors.
First we have the histogram data structure and routines for creating it.
The number of bits of precision can be adjusted by changing these symbols.
We recommend keeping 6 bits for G and 5 each for R and B.
If you have plenty of memory and cycles, 6 bits all around gives marginally
better results; if you are short of memory, 5 bits all around will save
some space but degrade the results.
To maintain a fully accurate histogram, we'd need to allocate a "long"
(preferably unsigned long) for each cell. In practice this is overkill;
we can get by with 16 bits per cell. Few of the cell counts will overflow,
and clamping those that do overflow to the maximum value will give close-
enough results. This reduces the recommended histogram size from 256Kb
to 128Kb, which is a useful savings on PC-class machines.
(In the second pass the histogram space is re-used for pixel mapping data;
in that capacity, each cell must be able to store zero to the number of
desired colors. 16 bits/cell is plenty for that too.)
Since the JPEG code is intended to run in small memory model on 80x86
machines, we can't just allocate the histogram in one chunk. Instead
of a true 3-D array, we use a row of pointers to 2-D arrays. Each
pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and
each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that
on 80x86 machines, the pointer row is in near memory but the actual
arrays are in far memory (same arrangement as we use for image arrays).
Declarations for Floyd-Steinberg dithering.
Errors are accumulated into the array fserrors[], at a resolution of
1/16th of a pixel count. The error at a given pixel is propagated
to its not-yet-processed neighbors using the standard F-S fractions,
... (here) 7/16
3/16 5/16 1/16
We work left-to-right on even rows, right-to-left on odd rows.
We can get away with a single array (holding one row's worth of errors)
by using it to store the current row's errors at pixel columns not yet
processed, but the next row's errors at columns already processed. We
need only a few extra variables to hold the errors immediately around the
current column. (If we are lucky, those variables are in registers, but
even if not, they're probably cheaper to access than array elements are.)
The fserrors[] array has (#columns + 2) entries; the extra entry at
each end saves us from special-casing the first and last pixels.
Each entry is three values long, one value for each color component.
Module initialization routine for 2-pass color quantization.
Initialize for each processing pass.
Switch to a new external colormap between output passes.
Prescan some rows of pixels.
In this module the prescan simply updates the histogram, which has been
initialized to zeroes by start_pass.
An output_buf parameter is required by the method signature, but no data
is actually output (in fact the buffer controller is probably passing a
null pointer).
Map some rows of pixels to the output colormapped representation.
This version performs Floyd-Steinberg dithering
Map some rows of pixels to the output colormapped representation.
This version performs no dithering
Finish up at the end of each pass.
Compute representative color for a box, put it in colormap[icolor]
Master routine for color selection
Repeatedly select and split the largest box until we have enough boxes
Find the splittable box with the largest color population
Returns null if no splittable boxes remain
Find the splittable box with the largest (scaled) volume
Returns null if no splittable boxes remain
Shrink the min/max bounds of a box to enclose only nonzero elements,
and recompute its volume and population
Initialize the error-limiting transfer function (lookup table).
The raw F-S error computation can potentially compute error values of up to
+- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be
much less, otherwise obviously wrong pixels will be created. (Typical
effects include weird fringes at color-area boundaries, isolated bright
pixels in a dark area, etc.) The standard advice for avoiding this problem
is to ensure that the "corners" of the color cube are allocated as output
colors; then repeated errors in the same direction cannot cause cascading
error buildup. However, that only prevents the error from getting
completely out of hand; Aaron Giles reports that error limiting improves
the results even with corner colors allocated.
A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty
well, but the smoother transfer function used below is even better. Thanks
to Aaron Giles for this idea.
Locate the colormap entries close enough to an update box to be candidates
for the nearest entry to some cell(s) in the update box. The update box
is specified by the center coordinates of its first cell. The number of
candidate colormap entries is returned, and their colormap indexes are
placed in colorlist[].
This routine uses Heckbert's "locally sorted search" criterion to select
the colors that need further consideration.
Find the closest colormap entry for each cell in the update box,
given the list of candidate colors prepared by find_nearby_colors.
Return the indexes of the closest entries in the bestcolor[] array.
This routine uses Thomas' incremental distance calculation method to
find the distance from a colormap entry to successive cells in the box.
Fill the inverse-colormap entries in the update box that contains
histogram cell c0/c1/c2. (Only that one cell MUST be filled, but
we can fill as many others as we wish.)
Process some data in the single-pass case.
We process the equivalent of one fully interleaved MCU row ("iMCU" row)
per call, ie, v_samp_factor block rows for each component in the image.
Returns true if the iMCU row is completed, false if suspended.
NB: input_buf contains a plane for each component in image,
which we index according to the component's SOF position.
Process some data in the first pass of a multi-pass case.
We process the equivalent of one fully interleaved MCU row ("iMCU" row)
per call, ie, v_samp_factor block rows for each component in the image.
This amount of data is read from the source buffer, DCT'd and quantized,
and saved into the virtual arrays. We also generate suitable dummy blocks
as needed at the right and lower edges. (The dummy blocks are constructed
in the virtual arrays, which have been padded appropriately.) This makes
it possible for subsequent passes not to worry about real vs. dummy blocks.
We must also emit the data to the entropy encoder. This is conveniently
done by calling compress_output() after we've loaded the current strip
of the virtual arrays.
NB: input_buf contains a plane for each component in image. All
components are DCT'd and loaded into the virtual arrays in this pass.
However, it may be that only a subset of the components are emitted to
the entropy encoder during this first pass; be careful about looking
at the scan-dependent variables (MCU dimensions, etc).
Process some data in subsequent passes of a multi-pass case.
We process the equivalent of one fully interleaved MCU row ("iMCU" row)
per call, ie, v_samp_factor block rows for each component in the scan.
The data is obtained from the virtual arrays and fed to the entropy coder.
Returns true if the iMCU row is completed, false if suspended.
Expanded data destination object for output to Stream
Initialize destination --- called by jpeg_start_compress
before any data is actually written.
Empty the output buffer --- called whenever buffer fills up.
In typical applications, this should write the entire output buffer
(ignoring the current state of next_output_byte and free_in_buffer),
reset the pointer and count to the start of the buffer, and return true
indicating that the buffer has been dumped.
In applications that need to be able to suspend compression due to output
overrun, a false return indicates that the buffer cannot be emptied now.
In this situation, the compressor will return to its caller (possibly with
an indication that it has not accepted all the supplied scanlines). The
application should resume compression after it has made more room in the
output buffer. Note that there are substantial restrictions on the use of
suspension --- see the documentation.
When suspending, the compressor will back up to a convenient restart point
(typically the start of the current MCU). next_output_byte and free_in_buffer
indicate where the restart point will be if the current call returns false.
Data beyond this point will be regenerated after resumption, so do not
write it out when emptying the buffer externally.
Terminate destination --- called by jpeg_finish_compress
after all data has been written. Usually needs to flush buffer.
NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
application must deal with any cleanup that should happen even
for error exit.
Initialize for an upsampling pass.
Control routine to do upsampling (and color conversion).
The control routine just handles the row buffering considerations.
1:1 vertical sampling case: much easier, never need a spare row.
Control routine to do upsampling (and color conversion).
The control routine just handles the row buffering considerations.
2:1 vertical sampling case: may need a spare row.
Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
Initialize tables for YCbCr->RGB colorspace conversion.
This is taken directly from jpeg_color_deconverter; see that file for more info.
Initialize tables for BG_YCC->RGB colorspace conversion.
This is taken directly from jpeg_color_deconverter; see that file for more info.
Expanded data source object for stdio input
Initialize source - called by jpeg_read_header
before any data is actually read.
Fill the input buffer - called whenever buffer is emptied.
In typical applications, this should read fresh data into the buffer
(ignoring the current state of next_input_byte and bytes_in_buffer),
reset the pointer and count to the start of the buffer, and return true
indicating that the buffer has been reloaded. It is not necessary to
fill the buffer entirely, only to obtain at least one more byte.
There is no such thing as an EOF return. If the end of the file has been
reached, the routine has a choice of ERREXIT() or inserting fake data into
the buffer. In most cases, generating a warning message and inserting a
fake EOI marker is the best course of action --- this will allow the
decompressor to output however much of the image is there. However,
the resulting error message is misleading if the real problem is an empty
input file, so we handle that case specially.
In applications that need to be able to suspend compression due to input
not being available yet, a false return indicates that no more data can be
obtained right now, but more may be forthcoming later. In this situation,
the decompressor will return to its caller (with an indication of the
number of scanlines it has read, if any). The application should resume
decompression after it has loaded more data into the input buffer. Note
that there are substantial restrictions on the use of suspension --- see
the documentation.
When suspending, the decompressor will back up to a convenient restart point
(typically the start of the current MCU). next_input_byte and bytes_in_buffer
indicate where the restart point will be if the current call returns false.
Data beyond this point must be rescanned after resumption, so move it to
the front of the buffer rather than discarding it.
This is a special implementation of the coefficient
buffer controller. This is similar to jccoefct.c, but it handles only
output from presupplied virtual arrays. Furthermore, we generate any
dummy padding blocks on-the-fly rather than expecting them to be present
in the arrays.
Initialize coefficient buffer controller.
Each passed coefficient array must be the right size for that
coefficient: width_in_blocks wide and height_in_blocks high,
with unit height at least v_samp_factor.
Initialize for a processing pass.
Process some data.
We process the equivalent of one fully interleaved MCU row ("iMCU" row)
per call, ie, v_samp_factor block rows for each component in the scan.
The data is obtained from the virtual arrays and fed to the entropy coder.
Returns true if the iMCU row is completed, false if suspended.
NB: input_buf is ignored; it is likely to be a null pointer.
Reset within-iMCU-row counters for a new row
Initialize for an upsampling pass.
Control routine to do upsampling (and color conversion).
In this version we upsample each component independently.
We upsample one row group into the conversion buffer, then apply
color conversion a row at a time.
This is a no-op version used for "uninteresting" components.
These components will not be referenced by color conversion.
For full-size components, we just make color_buf[ci] point at the
input buffer, and thus avoid copying any data. Note that this is
safe only because sep_upsample doesn't declare the input row group
"consumed" until we are done color converting and emitting it.
Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
It's still a box filter.
Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
It's still a box filter.
This version handles any integral sampling ratios.
This is not used for typical JPEG files, so it need not be fast.
Nor, for that matter, is it particularly accurate: the algorithm is
simple replication of the input pixel onto the corresponding output
pixels. The hi-falutin sampling literature refers to this as a
"box filter". A box filter tends to introduce visible artifacts,
so if you are actually going to use 3:1 or 4:1 sampling ratios
you would be well advised to improve this code.
One block of coefficients.
Gets or sets the element at the specified index.
The index of required element.
The required element.
Huffman coding table.
Gets or sets a value indicating whether the table has been output to file.
It's initialized false when the table is created, and set
true when it's been output to the file. You could suppress output
of a table by setting this to true.
This property is used only during compression. It's initialized
false when the table is created, and set true when it's been
output to the file. You could suppress output of a table by setting this to
true. (See jpeg_suppress_tables for an example.)
Defines some JPEG constants.
The basic DCT block is 8x8 coefficients
DCTSIZE squared; the number of elements in a block.
Quantization tables are numbered 0..3
Huffman tables are numbered 0..3
Arith-coding tables are numbered 0..15
JPEG limit on the number of components in one scan.
Compressor's limit on blocks per MCU.
Decompressor's limit on blocks per MCU.
JPEG limit on sampling factors.
Maximum number of color channels allowed in JPEG image.
The size of sample.
Are either:
8 - for 8-bit sample values (the usual setting)
9 - for 9-bit sample values
10 - for 10-bit sample values
11 - for 11-bit sample values
12 - for 12-bit sample values (not supported by this version)
Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
full-feature DCT processing.Further depths up to 16-bit may be added
later for the lossless modes of operation.
Run-time selection and conversion of data precision will be added later
and are currently not supported, sorry.
Exception: The transcoding part(jpegtran) supports all settings in a
single instance, since it operates on the level of DCT coefficients and
not sample values.The DCT coefficients are of the same type(16 bits)
in all cases(see below).
DCT method used by default.
Fastest DCT method.
A tad under 64K to prevent overflows.
The maximum sample value.
The medium sample value.
Offset of Red in an RGB scanline element.
Offset of Green in an RGB scanline element.
Offset of Blue in an RGB scanline element.
Bytes per RGB scanline element.
The number of bits of lookahead.
Base class for both JPEG compressor and decompresor.
Routines that are to be used by both halves of the library are declared
to receive an instance of this class. There are no actual instances of
, only of
and
Base constructor.
Base constructor.
The error manager.
Gets a value indicating whether this instance is Jpeg decompressor.
true if this is Jpeg decompressor; otherwise, false.
Progress monitor.
The progress manager.
Default value: null.
Error handler module.
The error manager.
Error handling
Gets the version of LibJpeg.
The version of LibJpeg.
Gets the LibJpeg's copyright.
The copyright.
Creates the array of samples.
The number of samples in row.
The number of rows.
The array of samples.
Creates the array of blocks.
The number of blocks in row.
The number of rows.
The array of blocks.
Creates 2-D sample array.
The number of samples per row.
The number of rows.
The array of samples.
Abort processing of a JPEG compression or decompression operation,
but don't destroy the object itself.
Closing a data source or destination, if necessary, is the
application's responsibility.
Destruction of a JPEG object.
Closing a data source or destination, if necessary, is the
application's responsibility.
Used for fatal errors (print message and exit).
The message code.
Used for fatal errors (print message and exit).
The message code.
The parameters of message.
Used for fatal errors (print message and exit).
The message code.
The parameters of message.
Used for non-fatal errors (we can keep going, but the data is probably corrupt).
The message code.
Used for non-fatal errors (we can keep going, but the data is probably corrupt).
The message code.
The parameters of message.
Used for non-fatal errors (we can keep going, but the data is probably corrupt).
The message code.
The parameters of message.
Shows informational and debugging messages.
See for description.
The message code.
Shows informational and debugging messages.
See for description.
The message code.
The parameters of message.
Shows informational and debugging messages.
See for description.
The message code.
The parameters of message.
Basic info about one component (color channel).
Identifier for this component (0..255)
The component ID.
Its index in SOF or .
The component index.
Horizontal sampling factor (1..4)
The horizontal sampling factor.
Vertical sampling factor (1..4)
The vertical sampling factor.
Quantization table selector (0..3)
The quantization table selector.
DC entropy table selector (0..3)
The DC entropy table selector.
AC entropy table selector (0..3)
The AC entropy table selector.
Gets or sets the width in blocks.
The width in blocks.
Gets the downsampled width.
The downsampled width.
JPEG compression routine.
The scale numerator
The scale denomenator
corresponding scale factors (percentage, initialized 100).
TRUE=apply fancy downsampling
Color transform identifier, writes LSE marker if nonzero
the basic DCT block size: 1..16
Initializes a new instance of the class.
Initializes a new instance of the class.
The error manager.
Retrieves false because this is not decompressor.
false
Gets or sets the destination for compressed data
The destination for compressed data.
Gets or sets the width of image, in pixels.
The width of image.
Compression details
Gets or sets the height of image, in pixels.
The height of image.
Compression details
Gets or sets the number of color channels (components per pixel)
The number of color channels.
Compression details
Gets or sets the color space of source image.
The color space.
Compression details
Special color spaces
Gets or sets the number of bits of precision in image data.
Default value: 8
The number of bits.
The data precision.
Gets or sets the number of color components for JPEG color space.
The number of color components for JPEG color space.
Gets or sets the JPEG color space.
We recommend to use if you want to change this.
The JPEG color space.
Gets or sets a value indicating whether you will be supplying raw data.
Default value: false
true if you will be supplying raw data; otherwise, false.
Gets or sets a value indicating a way of using Huffman coding tables.
When this is true, you need not supply Huffman tables at all, and any you do supply will be overwritten.
true causes the compressor to compute optimal Huffman coding tables
for the image. This requires an extra pass over the data and therefore costs a good
deal of space and time. The default is false, which tells the compressor to use the
supplied or default Huffman tables. In most cases optimal tables save only a few
percent of file size compared to the default tables.
Compression parameter selection
Gets or sets a value indicating whether first samples are cosited.
true if first samples are cosited; otherwise, false.
Gets or sets the coefficient of image smoothing.
Default value: 0
If non-zero, the input image is smoothed; the value should be 1 for minimal smoothing
to 100 for maximum smoothing.
The coefficient of image smoothing.
Compression parameter selection
Gets or sets the algorithm used for the DCT step.
The DCT algorithm.
Compression parameter selection
Gets or sets the exact interval in MCU blocks.
Default value: 0
One restart marker per MCU row is often a good choice. The overhead of restart markers
is higher in grayscale JPEG files than in color files, and MUCH higher in progressive JPEGs.
If you use restarts, you may want to use larger intervals in those cases.
The restart interval.
Compression parameter selection
Gets or sets the interval in MCU rows.
Default value: 0
If Restart_in_rows is not 0, then is set
after the image width in MCUs is computed.
One restart marker per MCU row is often a good choice.
The overhead of restart markers is higher in grayscale JPEG files than in color files, and MUCH higher in progressive JPEGs. If you use restarts, you may want to use larger intervals in those cases.
The restart interval in MCU rows.
Compression parameter selection
Gets or sets a value indicating whether the JFIF APP0 marker is emitted.
and
set this true
if a JFIF-legal JPEG color space (i.e., YCbCr or grayscale) is selected, otherwise false.
true if JFIF APP0 marker is emitted; otherwise, false.
Compression parameter selection
Gets or sets the version number to be written into the JFIF marker.
initializes the version to
1.01 (major=minor=1). You should set it to 1.02 (major=1, minor=2) if you plan to write any
JFIF 1.02 extension markers.
The version number to be written into the JFIF marker.
Gets or sets the version number to be written into the JFIF marker.
initializes the version to
1.01 (major=minor=1). You should set it to 1.02 (major=1, minor=2) if you plan to write any
JFIF 1.02 extension markers.
The version number to be written into the JFIF marker.
Gets or sets the resolution information to be written into the JFIF marker; not used otherwise.
Default value:
The pixel aspect ratio is defined by
/
even when Density_unit is Unknown.
The density unit.
Compression parameter selection
Gets or sets the horizontal component of pixel ratio.
Default value: 1
The horizontal density.
Gets or sets the vertical component of pixel ratio.
Default value: 1
The vertical density.
Gets or sets a value indicating whether to emit Adobe APP14 marker.
and
set this true if JPEG color space RGB, CMYK, or YCCK is selected, otherwise false.
It is generally a bad idea to set both and
.
In fact, you probably shouldn't change the default settings at all - the default behavior ensures that the JPEG file's
color space can be recognized by the decoder.
If true an Adobe APP14 marker is emitted; false, otherwise.
Compression parameter selection
Gets the largest vertical sample factor.
The largest vertical sample factor.
Compression parameter selection
Gets the components that appears in SOF.
The component info array.
Gets the coefficient quantization tables.
The coefficient quantization tables or null if not defined.
Gets the Huffman coding tables.
The Huffman coding tables or null if not defined.
Gets the Huffman coding tables.
The Huffman coding tables or null if not defined.
Gets the index of next scanline to be written to .
Application may use this to control its processing loop,
e.g., "while (Next_scanline < Image_height)"
Range: from 0 to (Image_height - 1)
Abort processing of a JPEG compression operation.
Forcibly suppress or un-suppress all quantization and Huffman tables.
Marks all currently defined tables as already written (if suppress)
or not written (if !suppress). This will control whether they get
emitted by a subsequent call.
This routine is exported for use by applications that want to produce
abbreviated JPEG datastreams.
if set to true then suppress tables;
otherwise unsuppress.
Finishes JPEG compression.
If a multipass operating mode was selected, this may do a great
deal of work including most of the actual output.
Write a special marker.
This is only recommended for writing COM or APPn markers.
Must be called after and before first call to
or .
Specify the marker type parameter as .COM for COM or
.APP0 + n for APPn. (Actually, jpeg_write_marker will let you write any marker type,
but we don't recommend writing any other kinds of marker)
The data associated with the marker.
Special markers
Writes special marker's header.
Special marker.
Length of data associated with the marker.
After calling this method you need to call
exactly the number of times given in the length parameter.
This method lets you empty the output buffer partway through a marker, which might be important when
using a suspending data destination module. In any case, if you are using a suspending destination,
you should flush its buffer after inserting any special markers.
Special markers
Writes a byte of special marker's data.
The byte of data.
Alternate compression function: just write an abbreviated table file.
Before calling this, all parameters and a data destination must be set up.
To produce a pair of files containing abbreviated tables and abbreviated
image data, one would proceed as follows:
Initialize JPEG object
Set JPEG parameters
Set destination to table file
jpeg_write_tables();
Set destination to image file
jpeg_start_compress(false);
Write data...
jpeg_finish_compress();
jpeg_write_tables has the side effect of marking all tables written
(same as jpeg_suppress_tables(true)).
Thus a subsequent jpeg_start_compress
will not re-emit the tables unless it is passed write_all_tables=true.
Sets output stream.
The output stream.
The caller must have already opened the stream, and is responsible
for closing it after finishing compression.
Compression details
Jpeg_set_defaultses this instance.
Uses only the input image's color space (property ,
which must already be set in ). Many applications will only need
to use this routine and perhaps .
Compression parameter selection
Set the JPEG colorspace (property ,
and choose colorspace-dependent parameters appropriately.
The required colorspace.
See Special color spaces,
below, before using this. A large number of parameters, including all per-component parameters,
are set by this routine; if you want to twiddle individual parameters you should call
jpeg_set_colorspace before rather than after.
Compression parameter selection
Special color spaces
Select an appropriate JPEG colorspace based on ,
and calls
This is actually a subroutine of .
It's broken out in case you want to change just the colorspace-dependent JPEG parameters.
Compression parameter selection
Constructs JPEG quantization tables appropriate for the indicated quality setting.
The quality value is expressed on the 0..100 scale recommended by IJG.
If true, then the quantization table entries are constrained
to the range 1..255 for full JPEG baseline compatibility. In the current implementation,
this only makes a difference for quality settings below 25, and it effectively prevents
very small/low quality files from being generated. The IJG decoder is capable of reading
the non-baseline files generated at low quality settings when force_baseline is false,
but other decoders may not be.
Note that the exact mapping from quality values to tables may change in future IJG releases
as more is learned about DCT quantization.
Compression parameter selection
Set or change the 'quality' (quantization) setting, using default tables
and straight percentage-scaling quality scales.
This entry point allows different scalings for luminance and chrominance.
if set to true then baseline version is forced.
Same as except that the generated tables are the
sample tables given in the JPEG specification section K.1, multiplied by
the specified scale factor.
The scale_factor.
If true, then the quantization table entries are
constrained to the range 1..255 for full JPEG baseline compatibility. In the current
implementation, this only makes a difference for quality settings below 25, and it
effectively prevents very small/low quality files from being generated. The IJG decoder
is capable of reading the non-baseline files generated at low quality settings when
force_baseline is false, but other decoders may not be.
Note that larger scale factors give lower quality. This entry point is
useful for conforming to the Adobe PostScript DCT conventions, but we do not
recommend linear scaling as a user-visible quality scale otherwise.
Compression parameter selection
Allows an arbitrary quantization table to be created.
Indicates which table slot to fill.
An array of 64 unsigned integers given in normal array order.
These values are multiplied by scale_factor/100 and then clamped to the range 1..65535
(or to 1..255 if force_baseline is true).
The basic table should be given in JPEG zigzag order.
Multiplier for values in basic_table.
Defines range of values in basic_table.
If true - 1..255, otherwise - 1..65535.
Compression parameter selection
Converts a value on the IJG-recommended quality scale to a linear scaling percentage.
The IJG-recommended quality scale. Should be 0 (terrible) to 100 (very good).
The linear scaling percentage.
Compression parameter selection
Generates a default scan script for writing a progressive-JPEG file.
This is the recommended method of creating a progressive file, unless you want
to make a custom scan sequence. You must ensure that the JPEG color space is
set correctly before calling this routine.
Compression parameter selection
Starts JPEG compression.
Write or not write all quantization and Huffman tables.
Before calling this, all parameters and a data destination must be set up.
Compression details
Write some scanlines of data to the JPEG compressor.
The array of scanlines.
The number of scanlines for writing.
The return value will be the number of lines actually written.
This should be less than the supplied num_lines only in case that
the data destination module has requested suspension of the compressor,
or if more than image_height scanlines are passed in.
We warn about excess calls to jpeg_write_scanlines() since this likely
signals an application programmer error. However, excess scanlines passed in the last
valid call are "silently" ignored, so that the application need not adjust num_lines
for end-of-image when using a multiple-scanline buffer.
Compression details
Alternate entry point to write raw data.
The raw data.
The number of scanlines for writing.
The number of lines actually written.
Processes exactly one iMCU row per call, unless suspended.
Replaces when writing raw downsampled data.
Compression initialization for writing raw-coefficient data. Useful for lossless transcoding.
The virtual arrays need not be filled or even realized at the time
jpeg_write_coefficients is called; indeed, the virtual arrays typically will be realized
during this routine and filled afterwards.
Before calling this, all parameters and a data destination must be set up.
Call to actually write the data.
Initialization of a JPEG compression object
Master selection of compression modules.
This is done once at the start of processing an image. We determine
which modules will be used and give them appropriate initialization calls.
This routine is in charge of selecting the modules to be executed and
making an initialization call to each one.
Initialize master compression control.
Initialize main buffer controller.
Master selection of compression modules for transcoding.
Do computations that are needed before master selection phase
Verify that the scan script in scan_info[] is valid;
also determine whether it uses progressive JPEG, and set progressive_mode.
Set up the standard Huffman tables (cf. JPEG standard section K.3)
IMPORTANT: these are only valid for 8-bit data precision!
Define a Huffman table
Support routine: generate one scan for specified component
Support routine: generate interleaved DC scan if possible, else N scans
Support routine: generate one scan for each component
JPEG decompression routine.
The delegate for application-supplied marker processing methods.
Decompressor.
Return true to indicate success. false should be returned only
if you are using a suspending data source and it tells you to suspend.
Although the marker code is not explicitly passed, the routine can find it
in the . At the time of call,
the marker proper has been read from the data source module. The processor routine
is responsible for reading the marker length word and the remaining parameter bytes, if any.
Initializes a new instance of the class.
Initializes a new instance of the class.
The error manager.
Retrieves true because this is a decompressor.
true
Gets or sets the source for decompression.
The source for decompression.
Gets the width of image, set by
The width of image.
Decompression parameter selection
Gets the height of image, set by
The height of image.
Decompression parameter selection
Gets the number of color components in JPEG image.
The number of color components.
Decompression parameter selection
Gets or sets the colorspace of JPEG image.
The colorspace of JPEG image.
Decompression parameter selection
Gets the list of loaded special markers.
All the special markers in the file appear in this list, in order of
their occurrence in the file (but omitting any markers of types you didn't ask for)
The list of loaded special markers.
Special markers
Gets or sets the output color space.
The output color space.
Decompression parameter selection
Gets or sets the numerator of the fraction of image scaling.
Scale the image by the fraction Scale_num/Scale_denom.
Default is 1/1, or no scaling. Currently, the only supported scaling ratios are 1/1, 1/2, 1/4, and 1/8.
(The library design allows for arbitrary scaling ratios but this is not likely to be implemented any time soon.)
Smaller scaling ratios permit significantly faster decoding since fewer pixels
need to be processed and a simpler DCT method can be used.
Decompression parameter selection
Gets or sets the denominator of the fraction of image scaling.
Scale the image by the fraction Scale_num/Scale_denom.
Default is 1/1, or no scaling. Currently, the only supported scaling ratios are 1/1, 1/2, 1/4, and 1/8.
(The library design allows for arbitrary scaling ratios but this is not likely to be implemented any time soon.)
Smaller scaling ratios permit significantly faster decoding since fewer pixels
need to be processed and a simpler DCT method can be used.
Decompression parameter selection
Gets or sets a value indicating whether to use buffered-image mode.
true if buffered-image mode is turned on; otherwise, false.
Buffered-image mode
Enable or disable raw data output.
true if raw data output is enabled; otherwise, false.
Default value: false
Set this to true before
if you need to obtain raw data output.
Gets or sets the algorithm used for the DCT step.
The algorithm used for the DCT step.
Decompression parameter selection
Enable or disable upsampling of chroma components.
If true, do careful upsampling of chroma components.
If false, a faster but sloppier method is used.
The visual impact of the sloppier method is often very small.
Default value: true
Decompression parameter selection
Apply interblock smoothing in early stages of decoding progressive JPEG files.
If true, interblock smoothing is applied in early stages of decoding progressive JPEG files;
if false, not. Early progression stages look "fuzzy" with smoothing, "blocky" without.
Default value: true
In any case, block smoothing ceases to be applied after the first few AC coefficients are
known to full accuracy, so it is relevant only when using
buffered-image mode for progressive images.
Decompression parameter selection
Colors quantization.
If set true, colormapped output will be delivered.
Default value: false, meaning that full-color output will be delivered.
Decompression parameter selection
Selects color dithering method.
Default value: .
Ignored if is false.
At present, ordered dither is implemented only in the single-pass, standard-colormap case.
If you ask for ordered dither when is true
or when you supply an external color map, you'll get F-S dithering.
Decompression parameter selection
Gets or sets a value indicating whether to use two-pass color quantization.
If true, an extra pass over the image is made to select a custom color map for the image.
This usually looks a lot better than the one-size-fits-all colormap that is used otherwise.
Ignored when the application supplies its own color map.
Default value: true
Ignored if is false.
Decompression parameter selection
Maximum number of colors to use in generating a library-supplied color map.
Default value: 256.
Ignored if is false.
The actual number of colors is returned in a .
Decompression parameter selection
Enable future use of 1-pass quantizer.
Default value: false
Significant only in buffered-image mode.
Buffered-image mode
Enable future use of external colormap.
Default value: false
Significant only in buffered-image mode.
Buffered-image mode
Enable future use of 2-pass quantizer.
Default value: false
Significant only in buffered-image mode.
Buffered-image mode
Gets the actual width of output image.
The width of output image.
Computed by .
You can also use to determine this value
in advance of calling .
Gets the actual height of output image.
The height of output image.
Computed by .
You can also use to determine this value
in advance of calling .
Gets the number of color components in .
Computed by .
You can also use to determine this value
in advance of calling .
The number of color components.
Decompression parameter selection
Gets the number of color components returned.
Computed by .
You can also use to determine this value
in advance of calling .
When quantizing colors,
Output_components is 1, indicating a single color map index per pixel.
Otherwise it equals to .
Decompression parameter selection
Gets the recommended height of scanline buffer.
In high-quality modes, Rec_outbuf_height is always 1, but some faster,
lower-quality modes set it to larger values (typically 2 to 4).
Computed by .
You can also use to determine this value
in advance of calling .
Rec_outbuf_height is the recommended minimum height (in scanlines)
of the buffer passed to .
If the buffer is smaller, the library will still work, but time will be wasted due
to unnecessary data copying. If you are going to ask for a high-speed processing mode,
you may as well go to the trouble of honoring Rec_outbuf_height so as to avoid data copying.
(An output buffer larger than Rec_outbuf_height lines is OK, but won't provide
any material speed improvement over that height.)
Decompression parameter selection
The number of colors in the color map.
The number of colors in the color map.
Decompression parameter selection
The color map, represented as a 2-D pixel array of rows
and columns.
Colormap is set to null by .
The application can supply a color map by setting Colormap non-null and setting
to the map size.
Ignored if not quantizing.
Implementation restriction: at present, an externally supplied Colormap
is only accepted for 3-component output color spaces.
Decompression parameter selection
Gets the number of scanlines returned so far.
The output_scanline.
Usually you can just use this variable as the loop counter,
so that the loop test looks like
while (cinfo.Output_scanline < cinfo.Output_height)
Decompression details
Gets the number of SOS markers seen so far.
The number of SOS markers seen so far.
Indicates the progress of the decompressor input side.
Gets the number of iMCU rows completed.
The number of iMCU rows completed.
Indicates the progress of the decompressor input side.
Gets the nominal scan number being displayed.
The nominal scan number being displayed.
Gets the number of iMCU rows read.
The number of iMCU rows read.
Gets the current progression status..
Coef_bits[c][i] indicates the precision with
which component c's DCT coefficient i (in zigzag order) is known.
It is -1 when no data has yet been received, otherwise
it is the point transform (shift) value for the most recent scan of the coefficient
(thus, 0 at completion of the progression). This is null when reading a non-progressive file.
Progressive JPEG support
Gets the resolution information from JFIF marker.
The information from JFIF marker.
Decompression parameter selection
Gets the horizontal component of pixel ratio.
The horizontal component of pixel ratio.
Gets the vertical component of pixel ratio.
The vertical component of pixel ratio.
Gets the data precision.
The data precision.
Gets the largest vertical sample factor.
The largest vertical sample factor.
Gets the last read and unprocessed JPEG marker.
It is either zero or the code of a JPEG marker that has been
read from the data source, but has not yet been processed.
Special markers
Comp_info[i] describes component that appears i'th in SOF
The components in SOF.
Sets input stream.
The input stream.
The caller must have already opened the stream, and is responsible
for closing it after finishing decompression.
Decompression details
Decompression startup: this will read the source datastream header markers, up to the beginning of the compressed data proper.
Read a description of Return Value.
If you pass require_image=true (normal case), you need not check for a
return code; an abbreviated file will cause
an error exit. is only possible if you use a data source
module that can give a suspension return.
This method will read as far as the first SOS marker (ie, actual start of compressed data),
and will save all tables and parameters in the JPEG object. It will also initialize the
decompression parameters to default values, and finally return .
On return, the application may adjust the decompression parameters and then call
. (Or, if the application only wanted to
determine the image parameters, the data need not be decompressed. In that case, call
to release any temporary space.)
If an abbreviated (tables only) datastream is presented, the routine will return
upon reaching EOI. The application may then re-use
the JPEG object to read the abbreviated image datastream(s). It is unnecessary (but OK) to call
jpeg_abort in this case.
The return code only occurs if the data source module
requests suspension of the decompressor. In this case the application should load more source
data and then re-call jpeg_read_header to resume processing.
If a non-suspending data source is used and require_image is true,
then the return code need not be inspected since only is possible.
Need only initialize JPEG object and supply a data source before calling.
On return, the image dimensions and other info have been stored in the JPEG object.
The application may wish to consult this information before selecting decompression parameters.
This routine is now just a front end to , with some extra error checking.
Decompression details
Decompression parameter selection
Decompression initialization.
Returns false if suspended. The return value need be inspected
only if a suspending data source is used.
jpeg_read_header must be completed before calling this.
If a multipass operating mode was selected, this will do all but the last pass, and thus may take a great deal of time.
Decompression details
Read some scanlines of data from the JPEG decompressor.
Buffer for filling.
Required number of lines.
The return value will be the number of lines actually read.
This may be less than the number requested in several cases, including
bottom of image, data source suspension, and operating modes that emit multiple scanlines at a time.
We warn about excess calls to jpeg_read_scanlines since this likely signals an
application programmer error. However, an oversize buffer (max_lines > scanlines remaining)
is not an error.
Decompression details
Finish JPEG decompression.
Returns false if suspended. The return value need be inspected
only if a suspending data source is used.
This will normally just verify the file trailer and release temp storage.
Decompression details
Alternate entry point to read raw data.
The raw data.
The number of scanlines for reading.
The number of lines actually read.
Replaces jpeg_read_scanlines
when reading raw downsampled data. Processes exactly one iMCU row per call, unless suspended.
Is there more than one scan?
true if image has more than one scan; otherwise, false
If you are concerned about maximum performance on baseline JPEG files,
you should use buffered-image mode only
when the incoming file actually has multiple scans. This can be tested by calling this method.
Initialize for an output pass in buffered-image mode.
Indicates which scan of the input file is to be displayed;
the scans are numbered starting at 1 for this purpose.
true if done; false if suspended
Buffered-image mode
Finish up after an output pass in buffered-image mode.
Returns false if suspended. The return value need be inspected only if a suspending data source is used.
Buffered-image mode
Indicates if we have finished reading the input file.
true if we have finished reading the input file.
Buffered-image mode
Consume data in advance of what the decompressor requires.
The result of data consumption.
This routine can be called at any time after initializing the JPEG object.
It reads some additional data and returns when one of the indicated significant events
occurs. If called after the EOI marker is reached, it will immediately return
without attempting to read more data.
Pre-calculate output image dimensions and related values for current decompression parameters.
This is allowed for possible use by application. Hence it mustn't do anything
that can't be done twice. Also note that it may be called before the master module is initialized!
Read or write the raw DCT coefficient arrays from a JPEG file (useful for lossless transcoding).
Returns null if suspended. This case need be checked only
if a suspending data source is used.
jpeg_read_header must be completed before calling this.
The entire image is read into a set of virtual coefficient-block arrays, one per component.
The return value is an array of virtual-array descriptors.
An alternative usage is to simply obtain access to the coefficient arrays during a
buffered-image mode decompression operation. This is allowed after any
jpeg_finish_output call. The arrays can be accessed
until jpeg_finish_decompress is called.
Note that any call to the library may reposition the arrays,
so don't rely on results to stay valid across library calls.
Initializes the compression object with default parameters, then copy from the source object
all parameters needed for lossless transcoding.
Target JPEG compression object.
Parameters that can be varied without loss (such as scan script and
Huffman optimization) are left in their default states.
Aborts processing of a JPEG decompression operation.
Sets processor for special marker.
The marker code.
The processor.
Allows you to supply your own routine to process
COM and/or APPn markers on-the-fly as they are read.
Special markers
Control saving of COM and APPn markers into Marker_list.
The marker type to save (see JPEG_MARKER enumeration).
To arrange to save all the special marker types, you need to call this
routine 17 times, for COM and APP0-APP15 markers.
If the incoming marker is longer than length_limit data bytes,
only length_limit bytes will be saved; this parameter allows you to avoid chewing up memory
when you only need to see the first few bytes of a potentially large marker. If you want to save
all the data, set length_limit to 0xFFFF; that is enough since marker lengths are only 16 bits.
As a special case, setting length_limit to 0 prevents that marker type from being saved at all.
(That is the default behavior, in fact.)
Special markers
Determine whether merged upsample/color conversion should be used.
CRUCIAL: this must match the actual capabilities of merged upsampler!
Initialization of JPEG compression objects.
The error manager must already be set up (in case memory manager fails).
Master selection of decompression modules for transcoding (that is, reading
raw DCT coefficient arrays from an input JPEG file.)
This substitutes for initialization of the full decompressor.
Set up for an output pass, and perform any dummy pass(es) needed.
Common subroutine for jpeg_start_decompress and jpeg_start_output.
Entry: global_state = DSTATE_PRESCAN only if previously suspended.
Exit: If done, returns true and sets global_state for proper output mode.
If suspended, returns false and sets global_state = DSTATE_PRESCAN.
Set default decompression parameters.
Data destination object for compression.
Initializes this instance.
Empties output buffer.
true if operation succeed; otherwise, false
Term_destinations this instance.
Emits a byte.
The byte value.
true if operation succeed; otherwise, false
Initializes the internal buffer.
The buffer.
The offset.
Gets the number of free bytes in buffer.
The number of free bytes in buffer.
Contains simple error-reporting and trace-message routines.
This class is used by both the compression and decompression code.
Error handling
Initializes a new instance of the class.
Gets or sets the maximum message level that will be displayed.
Values are:
-1: recoverable corrupt-data warning, may want to abort.
0: important advisory messages (always display to user).
1: first level of tracing detail.
2, 3, ...: successively more detailed tracing messages.
Gets the number of corrupt-data warnings.
The num_warnings.
For recoverable corrupt-data errors, we emit a warning message, but keep going
unless emit_message chooses to abort.
emit_message should count warnings in Num_warnings. The surrounding application
can check for bad data by seeing if Num_warnings is nonzero at the end of processing.
Receives control for a fatal error.
This method calls output_message
and then throws an exception.
Error handling
Conditionally emit a trace or warning message.
The message severity level.
Values are:
-1: recoverable corrupt-data warning, may want to abort.
0: important advisory messages (always display to user).
1: first level of tracing detail.
2, 3, ...: successively more detailed tracing messages.
The main reason for overriding this method would be to abort on warnings.
This method calls output_message for message showing.
An application might override this method if it wanted to abort on
warnings or change the policy about which messages to display.
Error handling
Actual output of any JPEG message.
Override this to send messages somewhere other than Console.
Note that this method does not know how to generate a message, only where to send it.
For extending a generation of messages see format_message.
Error handling
Constructs a readable error message string.
This method is called by output_message.
Few applications should need to override this method. One possible reason for doing so is to
implement dynamic switching of error message language.
The formatted message
Error handling
Resets error manager to initial state.
This is called during compression startup to reset trace/error
processing to default state. An application might possibly want to
override this method if it has additional error processing state.
Gets the actual message texts.
The message code. See for details.
The message text associated with code.
It may be useful for an application to add its own message texts that are handled
by the same mechanism. You can override GetMessageText for this purpose. If you number
the addon messages beginning at 1000 or so, you won't have to worry about conflicts
with the library's built-in messages.
Error handling
JPEG marker codes.
Special markers
Representation of special JPEG marker.
You can't create instance of this class manually.
Concrete objects are instantiated by library and you can get them
through Marker_list property.
Special markers
Gets the special marker.
The marker value.
Gets the full length of original data associated with the marker.
The length of original data associated with the marker.
This length excludes the marker length word, whereas the stored representation
within the JPEG file includes it. (Hence the maximum data length is really only 65533.)
Gets the data associated with the marker.
The data associated with the marker.
The length of this array doesn't exceed length_limit for the particular marker type.
Note that this length excludes the marker length word, whereas the stored representation
within the JPEG file includes it. (Hence the maximum data length is really only 65533.)
The progress monitor object.
Progress monitoring
Occurs when progress is changed.
Progress monitoring
Gets or sets the number of work units completed in this pass.
The number of work units completed in this pass.
Progress monitoring
Gets or sets the total number of work units in this pass.
The total number of work units in this pass.
Progress monitoring
Gets or sets the number of passes completed so far.
The number of passes completed so far.
Progress monitoring
Gets or sets the total number of passes expected.
The total number of passes expected.
Progress monitoring
Indicates that progress was changed.
Call this method if you change some progress parameters manually.
This method ensures happening of the OnProgress event.
Data source object for decompression.
Initializes this instance.
Fills input buffer
true if operation succeed; otherwise, false
Initializes the internal buffer.
The buffer.
The size.
Skip data - used to skip over a potentially large amount of
uninteresting data (such as an APPn marker).
The number of bytes to skip.
Writers of suspendable-input applications must note that skip_input_data
is not granted the right to give a suspension return. If the skip extends
beyond the data currently in the buffer, the buffer can be marked empty so
that the next read will cause a fill_input_buffer call that can suspend.
Arranging for additional bytes to be discarded before reloading the input
buffer is the application writer's problem.
This is the default resync_to_restart method for data source
managers to use if they don't have any better approach.
An instance of
The desired
false if suspension is required.
That method assumes that no backtracking is possible.
Some data source managers may be able to back up, or may have
additional knowledge about the data which permits a more
intelligent recovery strategy; such managers would
presumably supply their own resync method.
read_restart_marker calls resync_to_restart if it finds a marker other than
the restart marker it was expecting. (This code is *not* used unless
a nonzero restart interval has been declared.) cinfo.unread_marker is
the marker code actually found (might be anything, except 0 or FF).
The desired restart marker number (0..7) is passed as a parameter.
This routine is supposed to apply whatever error recovery strategy seems
appropriate in order to position the input stream to the next data segment.
Note that cinfo.unread_marker is treated as a marker appearing before
the current data-source input point; usually it should be reset to zero
before returning.
This implementation is substantially constrained by wanting to treat the
input as a data stream; this means we can't back up. Therefore, we have
only the following actions to work with:
1. Simply discard the marker and let the entropy decoder resume at next
byte of file.
2. Read forward until we find another marker, discarding intervening
data. (In theory we could look ahead within the current bufferload,
without having to discard data if we don't find the desired marker.
This idea is not implemented here, in part because it makes behavior
dependent on buffer size and chance buffer-boundary positions.)
3. Leave the marker unread (by failing to zero cinfo.unread_marker).
This will cause the entropy decoder to process an empty data segment,
inserting dummy zeroes, and then we will reprocess the marker.
#2 is appropriate if we think the desired marker lies ahead, while #3 is
appropriate if the found marker is a future restart marker (indicating
that we have missed the desired restart marker, probably because it got
corrupted).
We apply #2 or #3 if the found marker is a restart marker no more than
two counts behind or ahead of the expected one. We also apply #2 if the
found marker is not a legal JPEG marker code (it's certainly bogus data).
If the found marker is a restart marker more than 2 counts away, we do #1
(too much risk that the marker is erroneous; with luck we will be able to
resync at some future point).
For any valid non-restart JPEG marker, we apply #3. This keeps us from
overrunning the end of a scan. An implementation limited to single-scan
files might find it better to apply #2 for markers other than EOI, since
any other marker would have to be bogus data in that case.
Terminate source - called by jpeg_finish_decompress
after all data has been read. Often a no-op.
NB: not called by jpeg_abort or jpeg_destroy; surrounding
application must deal with any cleanup that should happen even
for error exit.
Reads two bytes interpreted as an unsigned 16-bit integer.
The result.
true if operation succeed; otherwise, false
Read a byte into variable V.
If must suspend, take the specified action (typically "return false").
The result.
true if operation succeed; otherwise, false
Gets the bytes.
The destination.
The amount.
The number of available bytes.
Functions for fetching data from the data source module.
true if operation succeed; otherwise, false
At all times, cinfo.src.next_input_byte and .bytes_in_buffer reflect
the current restart point; we update them only when we have reached a
suitable place to restart if a suspension occurs.
DCT coefficient quantization tables.
Gets or sets a value indicating whether the table has been output to file.
It's initialized false when the table is created, and set
true when it's been output to the file. You could suppress output of a table by setting this to true.
This property is used only during compression.
JPEG virtual array.
The type of array's elements.
You can't create virtual array manually. For creation use methods
and
.
Request a virtual 2-D array
Width of array
Total virtual array height
The allocator.
Gets or sets the error processor.
The error processor.
Default value: null
Uses only for calling
jpeg_common_struct.ERREXIT
on error.
Access the part of a virtual array.
The first row in required block.
The number of required rows.
The required part of virtual array.
Known color spaces.
Special color spaces
Unspecified color space.
Monochrome
Red/Green/Blue, standard RGB (sRGB)
Y/Cb/Cr (also known as YUV), standard YCC
C/M/Y/K
Y/Cb/Cr/K
big gamut red/green/blue, bg-sRGB
big gamut Y/Cb/Cr, bg-sYCC
N channels
Supported color transforms.
No transform
Substract green
Algorithm used for the DCT step.
The FLOAT method is very slightly more accurate than the ISLOW method,
but may give different results on different machines due to varying roundoff behavior.
The integer methods should give the same results on all machines. On machines with
sufficiently fast hardware, the floating-point method may also be the fastest.
The IFAST method is considerably less accurate than the other two; its use is not recommended
if high quality is a concern.
Slow but accurate integer algorithm.
Faster, less accurate integer method.
Floating-point method.
Dithering options for decompression.
No dithering: fast, very low quality
Ordered dither: moderate speed and quality
Floyd-Steinberg dither: slow, high quality
Message codes used in code to signal errors, warning and trace messages.
Must be first entry!
Describes a result of read operation.
Suspended due to lack of input data. Can occur only if a suspending data source is used.
Found valid image datastream.
Found valid table-specs-only datastream.
Reached a SOS marker (the start of a new scan)
Reached the EOI marker (end of image)
Completed reading one MCU row of compressed data.
Completed reading last MCU row of current scan.
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
This method returns the literal value received
The literal to return
The received value
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Performs an unsigned bitwise right shift with the specified number
Number to operate on
Ammount of bits to shift
The resulting number from the shift operation
Reads a number of characters from the current source Stream and writes the data to the target array at the specified index.
The source Stream to read from.
Contains the array of characteres read from the source Stream.
The starting index of the target array.
The maximum number of characters to read from the source Stream.
The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached.
Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index.
The source TextReader to read from
Contains the array of characteres read from the source TextReader.
The starting index of the target array.
The maximum number of characters to read from the source TextReader.
The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached.
Converts a string to an array of bytes
The string to be converted
The new array of bytes
Converts an array of bytes to an array of chars
The array of bytes to convert
The new array of chars
Returns the total number of bytes input so far.
Returns the total number of bytes output so far.
Returns the total number of bytes input so far.
Returns the total number of bytes output so far.