public class TiffOptions extends ImageOptionsBase
The tiff file format options. Note that width and height tags will get overwritten on image creation by width and height parameters so there is no need to specify them directly. Note that many options return a default value but that does not mean that this option is set explicitly as a tag value. To verify the tag is present use Tags property or the corresponding IsTagPresent method.
<developer_tip>
WARNING! never modify tiff options during save since this may cause side effects and hard to find bugs.
The following line was specially left commented since it caused incorrect determination of data beginning.
The passed options did not contain spp (although the options are not correct in such case but still this scenario causes errors)
and the next line caused +spp tag +bpp tag added and when options were written after data completely written they have overwritten
the data beginning for uncompressed codec!!! See TiffUncompressedCodec.Encode.
this.Options.SamplesPerPixel = 3;
</developer_tip>
This example demonstrates the use of different classes from SaveOptions Namespace for export purposes. An image of type Gif is loaded into an instance of Image and then exported out to several formats.
String dir = "c:\\temp\\"; //Load an existing image (of type Gif) in an instance of Image class com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.gif"); try { //Export to BMP file format using the default options image.save(dir + "output.bmp", new com.aspose.imaging.imageoptions.BmpOptions()); //Export to JPEG file format using the default options image.save(dir + "output.jpeg", new com.aspose.imaging.imageoptions.JpegOptions()); //Export to PNG file format using the default options image.save(dir + "output.png", new com.aspose.imaging.imageoptions.PngOptions()); //Export to TIFF file format using the default options image.save(dir + "output.tif", new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default)); } finally { image.dispose(); }
Constructor and Description |
---|
TiffOptions(int expectedFormat)
Initializes a new instance of the
TiffOptions class. |
TiffOptions(int expectedFormat,
int byteOrder)
Initializes a new instance of the
TiffOptions class. |
TiffOptions(TiffDataType[] tags)
Initializes a new instance of the
TiffOptions class. |
TiffOptions(TiffOptions options)
Initializes a new instance of the
TiffOptions class. |
Modifier and Type | Method and Description |
---|---|
void |
addTag(TiffDataType tagToAdd)
Adds a new tag.
|
void |
addTags(TiffDataType[] tagsToAdd)
Adds the tags.
|
int |
getAlphaStorage()
Gets or sets the alpha storage option.
|
String |
getArtist()
Gets or sets the artist.
|
int |
getBitsPerPixel()
Gets the bits per pixel.
|
int[] |
getBitsPerSample()
Gets the bits per sample.
|
int |
getByteOrder()
Gets or sets a value indicating the tiff byte order.
|
int[] |
getColorMap()
Gets or sets the color map.
|
int |
getCompression()
Gets the compression.
|
String |
getCopyright()
Gets the copyright.
|
String |
getDateTime()
Gets or sets the date and time.
|
int |
getDefaultMemoryAllocationLimit()
Deprecated.
Use com.aspose.imaging.Image.getBufferSizeHint, com.aspose.imaging.ImageOptionsBase.getBufferSizeHint or com.aspose.imaging.LoadOptions.getBufferSizeHint instead.
|
String |
getDocumentName()
Gets or sets the name of the document.
|
TiffExifIfd |
getExifIfd()
Gets or sets the pointer to EXIF IFD.
|
long |
getFaxT4Options()
Gets or sets the fax t4 options.
|
int |
getFileStandard()
Gets or sets the TIFF file standard.
|
int |
getFillOrder()
Gets or sets the byte bits fill order.
|
int[] |
getHalfToneHints()
Gets or sets the halftone hints.
|
byte[] |
getIccProfile()
Gets the icc profile stream.
|
String |
getImageDescription()
Gets or sets the image description.
|
long |
getImageLength()
Gets or sets the image length.
|
long |
getImageWidth()
Gets or sets the image width.
|
String |
getInkNames()
Gets or sets the ink names.
|
int[] |
getMaxSampleValue()
Gets or sets the max sample value.
|
int[] |
getMinSampleValue()
Gets or sets the min sample value.
|
int |
getOrientation()
Gets or sets the orientation.
|
String |
getPageName()
Gets or sets the page name.
|
int[] |
getPageNumber()
Gets or sets the page number tag.
|
IColorPalette |
getPalette()
Gets or sets the color palette.
|
int |
getPhotometric()
Gets or sets the photometric.
|
int |
getPlanarConfiguration()
Gets or sets the planar configuration.
|
int |
getPredictor()
Gets or sets the predictor for LZW compression.
|
boolean |
getPremultiplyComponents()
Gets or sets a value indicating whether components must be premultiplied.
|
ResolutionSetting |
getResolutionSettings()
Gets or sets the resolution settings.
|
int |
getResolutionUnit()
Gets or sets the resolution unit.
|
long |
getRowsPerStrip()
Gets or sets the rows per strip.
|
int[] |
getSampleFormat()
Gets or sets the sample format.
|
int |
getSamplesPerPixel()
Gets the samples per pixel.
|
String |
getScannerManufacturer()
Gets or sets the scanner manufacturer.
|
String |
getScannerModel()
Gets or sets the scanner model.
|
long[] |
getSmaxSampleValue()
Gets or sets the max sample value.
|
long[] |
getSminSampleValue()
Gets or sets the min sample value.
|
String |
getSoftwareType()
Gets or sets the software type.
|
long[] |
getStripByteCounts()
Gets or sets the strip byte counts.
|
long[] |
getStripOffsets()
Gets or sets the strip offsets.
|
long |
getSubFileType()
Gets or sets a general indication of the kind of data contained in this subfile.
|
TiffDataType |
getTagByType(int tagKey)
Gets the instance of the tag by type.
|
TiffDataType[] |
getTags()
Gets or sets the tags.
|
String |
getTargetPrinter()
Gets or sets the target printer.
|
int |
getThreshholding()
Gets or sets the threshholding.
|
long[] |
getTileByteCounts()
Gets or sets the tile byte counts.
|
long |
getTileLength()
Gets ot sets tile length.
|
long[] |
getTileOffsets()
Gets or sets the tile offsets.
|
long |
getTileWidth()
Gets ot sets tile width.
|
int |
getTotalPages()
Gets the total pages.
|
int |
getValidTagCount()
Gets the valid tag count.
|
static int |
getValidTagsCount(TiffDataType[] tags)
Gets the valid tags count.
|
XmpPacketWrapper |
getXmpData()
Gets or sets the XMP metadata container.
|
TiffRational |
getXposition()
Gets or sets the x position.
|
TiffRational |
getXresolution()
Gets or sets the x resolution.
|
TiffRational[] |
getYCbCrCoefficients()
Gets or sets the YCbCrCoefficients.
|
int[] |
getYCbCrSubsampling()
Gets or sets the subsampling factors for YCbCr photometric.
|
TiffRational |
getYposition()
Gets or sets the y position.
|
TiffRational |
getYresolution()
Gets or sets the y resolution.
|
boolean |
isExtraSamplesPresent()
Gets a value indicating whether the extra samples is present.
|
boolean |
isTagPresent(int tag)
Determines whether tag is present in the options or not.
|
boolean |
isTiled()
Gets a value indicating whether image is tiled.
|
boolean |
isValid()
Gets a value indicating whether the
TiffOptions have been properly configured. |
boolean |
removeTag(int tag)
Removes the tag.
|
void |
setAlphaStorage(int value)
Gets or sets the alpha storage option.
|
void |
setArtist(String value)
Gets or sets the artist.
|
void |
setBitsPerSample(int[] value)
Sets the bits per sample.
|
void |
setByteOrder(int value)
Gets or sets a value indicating the tiff byte order.
|
void |
setColorMap(int[] value)
Gets or sets the color map.
|
void |
setCompression(int value)
Sets the compression.
|
void |
setCopyright(String value)
Sets the copyright.
|
void |
setDateTime(String value)
Gets or sets the date and time.
|
void |
setDefaultMemoryAllocationLimit(int value)
Deprecated.
Use com.aspose.imaging.Image.setBufferSizeHint, com.aspose.imaging.ImageOptionsBase.setBufferSizeHint or com.aspose.imaging.LoadOptions.setBufferSizeHint instead.
|
void |
setDocumentName(String value)
Gets or sets the name of the document.
|
void |
setFaxT4Options(long value)
Gets or sets the fax t4 options.
|
void |
setFileStandard(int value)
Gets or sets the TIFF file standard.
|
void |
setFillOrder(int value)
Gets or sets the byte bits fill order.
|
void |
setHalfToneHints(int[] value)
Gets or sets the halftone hints.
|
void |
setIccProfile(byte[] value)
Sets the icc profile stream.
|
void |
setImageDescription(String value)
Gets or sets the image description.
|
void |
setImageLength(long value)
Gets or sets the image length.
|
void |
setImageWidth(long value)
Gets or sets the image width.
|
void |
setInkNames(String value)
Gets or sets the ink names.
|
void |
setMaxSampleValue(int[] value)
Gets or sets the max sample value.
|
void |
setMinSampleValue(int[] value)
Gets or sets the min sample value.
|
void |
setOrientation(int value)
Gets or sets the orientation.
|
void |
setPageName(String value)
Gets or sets the page name.
|
void |
setPageNumber(int[] value)
Gets or sets the page number tag.
|
void |
setPalette(IColorPalette value)
Gets or sets the color palette.
|
void |
setPhotometric(int value)
Gets or sets the photometric.
|
void |
setPlanarConfiguration(int value)
Gets or sets the planar configuration.
|
void |
setPredictor(int value)
Gets or sets the predictor for LZW compression.
|
void |
setPremultiplyComponents(boolean value)
Gets or sets a value indicating whether components must be premultiplied.
|
void |
setResolutionSettings(ResolutionSetting value)
Gets or sets the resolution settings.
|
void |
setResolutionUnit(int value)
Gets or sets the resolution unit.
|
void |
setRowsPerStrip(long value)
Gets or sets the rows per strip.
|
void |
setSampleFormat(int[] value)
Gets or sets the sample format.
|
void |
setScannerManufacturer(String value)
Gets or sets the scanner manufacturer.
|
void |
setScannerModel(String value)
Gets or sets the scanner model.
|
void |
setSmaxSampleValue(long[] value)
Gets or sets the max sample value.
|
void |
setSminSampleValue(long[] value)
Gets or sets the min sample value.
|
void |
setSoftwareType(String value)
Gets or sets the software type.
|
void |
setStripByteCounts(long[] value)
Gets or sets the strip byte counts.
|
void |
setStripOffsets(long[] value)
Gets or sets the strip offsets.
|
void |
setSubFileType(long value)
Gets or sets a general indication of the kind of data contained in this subfile.
|
void |
setTags(TiffDataType[] value)
Gets or sets the tags.
|
void |
setTargetPrinter(String value)
Gets or sets the target printer.
|
void |
setThreshholding(int value)
Gets or sets the threshholding.
|
void |
setTileByteCounts(long[] value)
Gets or sets the tile byte counts.
|
void |
setTileLength(long value)
Gets ot sets tile length.
|
void |
setTileOffsets(long[] value)
Gets or sets the tile offsets.
|
void |
setTileWidth(long value)
Gets ot sets tile width.
|
void |
setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata container.
|
void |
setXposition(TiffRational value)
Gets or sets the x position.
|
void |
setXresolution(TiffRational value)
Gets or sets the x resolution.
|
void |
setYCbCrCoefficients(TiffRational[] value)
Gets or sets the YCbCrCoefficients.
|
void |
setYCbCrSubsampling(int[] value)
Gets or sets the subsampling factors for YCbCr photometric.
|
void |
setYposition(TiffRational value)
Gets or sets the y position.
|
void |
setYresolution(TiffRational value)
Gets or sets the y resolution.
|
void |
validate()
Validates if options have valid combination of tags
|
deepClone, getBufferSizeHint, getMultiPageOptions, getProgressEventHandler, getSource, getVectorRasterizationOptions, setBufferSizeHint, setMultiPageOptions, setProgressEventHandler, setSource, setVectorRasterizationOptions
close, dispose, getDisposed
public TiffOptions(int expectedFormat, int byteOrder)
Initializes a new instance of the TiffOptions
class.
expectedFormat
- The expected tiff file format.byteOrder
- The tiff file format byte order to use.public TiffOptions(int expectedFormat)
Initializes a new instance of the TiffOptions
class. By default little endian convention is used.
expectedFormat
- The expected tiff file format.The following example shows how to create a grayscale copy of an existing frame and add it to a TIFF image.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions createTiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Create a permanent, not temporary file source. createTiffOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(dir + "multipage.tif", false)); createTiffOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); createTiffOptions.setBitsPerSample(new int[]{8, 8, 8}); com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = (com.aspose.imaging.fileformats.tiff.TiffImage) com.aspose.imaging.Image.create(createTiffOptions, 100, 100); try { // The linear gradient from the left-top to the right-bottom corner of the image. com.aspose.imaging.brushes.LinearGradientBrush brush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(tiffImage.getWidth(), tiffImage.getHeight()), com.aspose.imaging.Color.getRed(), com.aspose.imaging.Color.getGreen()); // Fill the active frame with a linear gradient brush. com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(tiffImage.getActiveFrame()); gr.fillRectangle(brush, tiffImage.getBounds()); // Grayscale options com.aspose.imaging.imageoptions.TiffOptions createTiffFrameOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); createTiffFrameOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0]))); createTiffFrameOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.MinIsBlack); createTiffFrameOptions.setBitsPerSample(new int[]{8}); // Create a grayscale copy of the active frame. // The pixel data is preserved but converted to the desired format. com.aspose.imaging.fileformats.tiff.TiffFrame grayscaleFrame = com.aspose.imaging.fileformats.tiff.TiffFrame.createFrameFrom(tiffImage.getActiveFrame(), createTiffFrameOptions); // Add the newly created frame to the TIFF image. tiffImage.addFrame(grayscaleFrame); tiffImage.save(); } finally { tiffImage.dispose(); }
public TiffOptions(TiffOptions options)
Initializes a new instance of the TiffOptions
class.
options
- The options to copy from.public TiffOptions(TiffDataType[] tags)
Initializes a new instance of the TiffOptions
class.
tags
- The tags to initialize options with.public static int getValidTagsCount(TiffDataType[] tags)
Gets the valid tags count.
tags
- The tags to validate.public int getFileStandard()
Gets or sets the TIFF file standard.
public void setFileStandard(int value)
Gets or sets the TIFF file standard.
value
- The TIFF file standard.@Deprecated public int getDefaultMemoryAllocationLimit()
Gets or sets the default memory allocation limit.
Image.getBufferSizeHint()
,
ImageOptionsBase.getBufferSizeHint()
,
LoadOptions.getBufferSizeHint()
@Deprecated public void setDefaultMemoryAllocationLimit(int value)
Gets or sets the default memory allocation limit.
value
- The default memory allocation limit.Image.setBufferSizeHint(int)
,
ImageOptionsBase.setBufferSizeHint(int)
,
LoadOptions.setBufferSizeHint(int)
public boolean getPremultiplyComponents()
Gets or sets a value indicating whether components must be premultiplied.
true
if components must be premultiplied; otherwise, false
.public void setPremultiplyComponents(boolean value)
Gets or sets a value indicating whether components must be premultiplied.
value
- true
if components must be premultiplied; otherwise, false
.public XmpPacketWrapper getXmpData()
Gets or sets the XMP metadata container.
getXmpData
in class ImageOptionsBase
public void setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata container.
setXmpData
in class ImageOptionsBase
value
- The XMP data container.public boolean isValid()
Gets a value indicating whether the TiffOptions
have been properly configured. Use Validate method as to find the failure reason.
true
if TiffOptions are properly configured; otherwise, false
.public int[] getYCbCrSubsampling()
Gets or sets the subsampling factors for YCbCr photometric.
TiffImageException
- Invalid field length. YCbCrSubsampling field must contain two values.com.aspose.ms.System.ArgumentNullException
- valuepublic void setYCbCrSubsampling(int[] value)
Gets or sets the subsampling factors for YCbCr photometric.
value
- The subsampling factors for YCbCr photometric.TiffImageException
- Invalid field length. YCbCrSubsampling field must contain two values.com.aspose.ms.System.ArgumentNullException
- valueThis example shows how to save a raster image to the TIFF format using various options.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions saveOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 8 bits for each color component. saveOptions.setBitsPerSample(new int[]{8, 8, 8}); // Set the Big Endian byte order (Motorola) saveOptions.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.BigEndian); // Set the LZW compression. saveOptions.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.Lzw); // Allow to reduce the size of continuous-tone images. // Currently this field is used only with LZW encoding because LZW is probably the only TIFF encoding scheme // that benefits significantly from a predictor step. saveOptions.setPredictor(com.aspose.imaging.fileformats.tiff.enums.TiffPredictor.Horizontal); // Set the RGB color model. saveOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); // For YCbCr, you can use one of the following choices: // YCbCrSubSampling field JPEG sampling factors // ---------------------------------------------- // 1,1 1x1, 1x1, 1x1 // 2,1 2x1, 1x1, 1x1 // 2,2(default value) 2x2, 1x1, 1x1 // saveOptions.YCbCrSubsampling = new ushort[] { 2, 2 }; // All color components will be stored within a single plane. saveOptions.setPlanarConfiguration(com.aspose.imaging.fileformats.tiff.enums.TiffPlanarConfigs.Contiguous); // Create a TIFF Frame of 100x100 px. com.aspose.imaging.Image image = new com.aspose.imaging.fileformats.bmp.BmpImage(100, 100); try { // Fill the entire image with the blue-yellow gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(image.getWidth(), image.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); graphics.fillRectangle(gradientBrush, image.getBounds()); image.save(dir + "output.tif", saveOptions); } finally { image.dispose(); }
public TiffRational[] getYCbCrCoefficients()
Gets or sets the YCbCrCoefficients.
TiffImageException
- Invalid count of rational coefficient values. Must be equal to 3.com.aspose.ms.System.ArgumentNullException
- valuepublic void setYCbCrCoefficients(TiffRational[] value)
Gets or sets the YCbCrCoefficients.
value
- The YCbCrCoefficients.TiffImageException
- Invalid count of rational coefficient values. Must be equal to 3.com.aspose.ms.System.ArgumentNullException
- valuepublic boolean isTiled()
Gets a value indicating whether image is tiled.
true
if image is tiled; otherwise, false
.public String getArtist()
Gets or sets the artist.
public void setArtist(String value)
Gets or sets the artist.
value
- The artist.public boolean isTagPresent(int tag)
Determines whether tag is present in the options or not.
tag
- The tag id to check.true
if tag is present; otherwise, false
.public int getByteOrder()
Gets or sets a value indicating the tiff byte order.
public void setByteOrder(int value)
Gets or sets a value indicating the tiff byte order.
This example shows how to save a raster image to the TIFF format using various options.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions saveOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 8 bits for each color component. saveOptions.setBitsPerSample(new int[]{8, 8, 8}); // Set the Big Endian byte order (Motorola) saveOptions.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.BigEndian); // Set the LZW compression. saveOptions.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.Lzw); // Allow to reduce the size of continuous-tone images. // Currently this field is used only with LZW encoding because LZW is probably the only TIFF encoding scheme // that benefits significantly from a predictor step. saveOptions.setPredictor(com.aspose.imaging.fileformats.tiff.enums.TiffPredictor.Horizontal); // Set the RGB color model. saveOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); // For YCbCr, you can use one of the following choices: // YCbCrSubSampling field JPEG sampling factors // ---------------------------------------------- // 1,1 1x1, 1x1, 1x1 // 2,1 2x1, 1x1, 1x1 // 2,2(default value) 2x2, 1x1, 1x1 // saveOptions.YCbCrSubsampling = new ushort[] { 2, 2 }; // All color components will be stored within a single plane. saveOptions.setPlanarConfiguration(com.aspose.imaging.fileformats.tiff.enums.TiffPlanarConfigs.Contiguous); // Create a TIFF Frame of 100x100 px. com.aspose.imaging.Image image = new com.aspose.imaging.fileformats.bmp.BmpImage(100, 100); try { // Fill the entire image with the blue-yellow gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(image.getWidth(), image.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); graphics.fillRectangle(gradientBrush, image.getBounds()); image.save(dir + "output.tif", saveOptions); } finally { image.dispose(); }
public byte[] getIccProfile()
Gets the icc profile stream.
public void setIccProfile(byte[] value)
Sets the icc profile stream.
value
- The icc profile.public int[] getBitsPerSample()
Gets the bits per sample.
When setting this value keep in mind that it will also set SamplesPerPixel value to array length. These 2 properties are very tightly coupled so may be set alltogether only.
public void setBitsPerSample(int[] value)
Sets the bits per sample.
value
- The bits per sample value.
When setting this value keep in mind that it will also set SamplesPerPixel value to array length. These 2 properties are very tightly coupled so may be set alltogether only.
The following example shows how to create a grayscale copy of an existing frame and add it to a TIFF image.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions createTiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Create a permanent, not temporary file source. createTiffOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(dir + "multipage.tif", false)); createTiffOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); createTiffOptions.setBitsPerSample(new int[]{8, 8, 8}); com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = (com.aspose.imaging.fileformats.tiff.TiffImage) com.aspose.imaging.Image.create(createTiffOptions, 100, 100); try { // The linear gradient from the left-top to the right-bottom corner of the image. com.aspose.imaging.brushes.LinearGradientBrush brush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(tiffImage.getWidth(), tiffImage.getHeight()), com.aspose.imaging.Color.getRed(), com.aspose.imaging.Color.getGreen()); // Fill the active frame with a linear gradient brush. com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(tiffImage.getActiveFrame()); gr.fillRectangle(brush, tiffImage.getBounds()); // Grayscale options com.aspose.imaging.imageoptions.TiffOptions createTiffFrameOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); createTiffFrameOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0]))); createTiffFrameOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.MinIsBlack); createTiffFrameOptions.setBitsPerSample(new int[]{8}); // Create a grayscale copy of the active frame. // The pixel data is preserved but converted to the desired format. com.aspose.imaging.fileformats.tiff.TiffFrame grayscaleFrame = com.aspose.imaging.fileformats.tiff.TiffFrame.createFrameFrom(tiffImage.getActiveFrame(), createTiffFrameOptions); // Add the newly created frame to the TIFF image. tiffImage.addFrame(grayscaleFrame); tiffImage.save(); } finally { tiffImage.dispose(); }
public int getCompression()
Gets the compression.
public void setCompression(int value)
Sets the compression.
value
- The compression.This example shows how to create a TIFF image with 2 frames and save it to a file.
String dir = "c:\\temp\\"; // Options for the first frame com.aspose.imaging.imageoptions.TiffOptions createOptions1 = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 8 bits for each color component. createOptions1.setBitsPerSample(new int[]{8, 8, 8}); // Set the Big Endian byte order (Motorola) createOptions1.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.BigEndian); // Set the LZW compression. createOptions1.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.Lzw); // Set the RGB color model. createOptions1.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); // All color components will be stored within a single plane. createOptions1.setPlanarConfiguration(com.aspose.imaging.fileformats.tiff.enums.TiffPlanarConfigs.Contiguous); // Create the first TIFF frame of 100x100 px. // Note that you don't have to dispose frames explicitly if they are included into TiffImage. // When the container is disposed all frames will be disposed automatically. com.aspose.imaging.fileformats.tiff.TiffFrame frame1 = new com.aspose.imaging.fileformats.tiff.TiffFrame(createOptions1, 100, 100); // Fill the first frame with the blue-yellow gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(frame1.getWidth(), frame1.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(frame1); graphics.fillRectangle(gradientBrush, frame1.getBounds()); // Options for the first frame com.aspose.imaging.imageoptions.TiffOptions createOptions2 = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 1 bit per pixel for a B/W image. createOptions2.setBitsPerSample(new int[]{1}); // Set the Little Endian byte order (Intel) createOptions2.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.LittleEndian); // Set the CCITT Group 3 Fax compression. createOptions2.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.CcittFax3); // Set the B/W color model where 0 is black, 1 is white. createOptions2.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.MinIsBlack); // Create the second TIFF frame of 200x200px. com.aspose.imaging.fileformats.tiff.TiffFrame frame2 = new com.aspose.imaging.fileformats.tiff.TiffFrame(createOptions2, 200, 200); // Fill the second frame with the blue-yellow gradient. // It will be automatically converted to the B/W format due to the corresponding settings of the frame. com.aspose.imaging.Graphics graphics2 = new com.aspose.imaging.Graphics(frame2); graphics2.fillRectangle(gradientBrush, frame2.getBounds()); // Create a TIFF image. com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = new com.aspose.imaging.fileformats.tiff.TiffImage( new com.aspose.imaging.fileformats.tiff.TiffFrame[]{frame1, frame2}); try { tiffImage.save(dir + "output.mutliframe.tif"); } finally { tiffImage.dispose(); }
public String getCopyright()
Gets the copyright.
public void setCopyright(String value)
Sets the copyright.
value
- The copyright.public int[] getColorMap()
Gets or sets the color map.
com.aspose.ms.System.ArgumentNullException
- valueTiffImageException
- The color map may be defined for samples per pixel equal to 1 only.
or
The bits per sample are not defined.com.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the followign formula: 3 * (2**BitsPerSample).public void setColorMap(int[] value)
Gets or sets the color map.
value
- The color map.com.aspose.ms.System.ArgumentNullException
- valueTiffImageException
- The color map may be defined for samples per pixel equal to 1 only.
or
The bits per sample are not defined.com.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the followign formula: 3 * (2**BitsPerSample).public IColorPalette getPalette()
Gets or sets the color palette.
getPalette
in class ImageOptionsBase
public void setPalette(IColorPalette value)
Gets or sets the color palette.
setPalette
in class ImageOptionsBase
value
- The color palette.public String getDateTime()
Gets or sets the date and time.
public void setDateTime(String value)
Gets or sets the date and time.
value
- The date and time.public String getDocumentName()
Gets or sets the name of the document.
public void setDocumentName(String value)
Gets or sets the name of the document.
value
- The name of the document.public int getAlphaStorage()
Gets or sets the alpha storage option. Options other than TiffAlphaStorage.Unspecified
are used when there are more than 3 SamplesPerPixel
defined.
public void setAlphaStorage(int value)
Gets or sets the alpha storage option. Options other than TiffAlphaStorage.Unspecified
are used when there are more than 3 SamplesPerPixel
defined.
value
- The alpha storage option.public boolean isExtraSamplesPresent()
Gets a value indicating whether the extra samples is present.
true
if the extra samples is present; otherwise, false
.public int getFillOrder()
Gets or sets the byte bits fill order.
public void setFillOrder(int value)
Gets or sets the byte bits fill order.
value
- The byte bits fill order.public int[] getHalfToneHints()
Gets or sets the halftone hints.
com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;Halftone hints array length must be equal to 2.public void setHalfToneHints(int[] value)
Gets or sets the halftone hints.
value
- The halftone hints.com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;Halftone hints array length must be equal to 2.public String getImageDescription()
Gets or sets the image description.
public void setImageDescription(String value)
Gets or sets the image description.
value
- The image description.public String getInkNames()
Gets or sets the ink names.
public void setInkNames(String value)
Gets or sets the ink names.
value
- The ink names.public String getScannerManufacturer()
Gets or sets the scanner manufacturer.
public void setScannerManufacturer(String value)
Gets or sets the scanner manufacturer.
value
- The scanner manufacturer.public int[] getMaxSampleValue()
Gets or sets the max sample value.
com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public void setMaxSampleValue(int[] value)
Gets or sets the max sample value.
value
- The max sample value.com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public int[] getMinSampleValue()
Gets or sets the min sample value.
com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public void setMinSampleValue(int[] value)
Gets or sets the min sample value.
value
- The min sample value.com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public String getScannerModel()
Gets or sets the scanner model.
public void setScannerModel(String value)
Gets or sets the scanner model.
value
- The scanner model.public int getOrientation()
Gets or sets the orientation.
public void setOrientation(int value)
Gets or sets the orientation.
value
- The orientation.public String getPageName()
Gets or sets the page name.
public void setPageName(String value)
Gets or sets the page name.
value
- The page name.public int[] getPageNumber()
Gets or sets the page number tag.
com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;Expected 2 values in the array: PageNumber[0] is the page number and PageNumber[1] is the total number of pages in the document.public void setPageNumber(int[] value)
Gets or sets the page number tag.
value
- The page number tag.com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;Expected 2 values in the array: PageNumber[0] is the page number and PageNumber[1] is the total number of pages in the document.public int getPhotometric()
Gets or sets the photometric.
TiffPhotometrics
public void setPhotometric(int value)
Gets or sets the photometric.
value
- The photometric.The following example shows how to create a grayscale copy of an existing frame and add it to a TIFF image.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions createTiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Create a permanent, not temporary file source. createTiffOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(dir + "multipage.tif", false)); createTiffOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); createTiffOptions.setBitsPerSample(new int[]{8, 8, 8}); com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = (com.aspose.imaging.fileformats.tiff.TiffImage) com.aspose.imaging.Image.create(createTiffOptions, 100, 100); try { // The linear gradient from the left-top to the right-bottom corner of the image. com.aspose.imaging.brushes.LinearGradientBrush brush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(tiffImage.getWidth(), tiffImage.getHeight()), com.aspose.imaging.Color.getRed(), com.aspose.imaging.Color.getGreen()); // Fill the active frame with a linear gradient brush. com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(tiffImage.getActiveFrame()); gr.fillRectangle(brush, tiffImage.getBounds()); // Grayscale options com.aspose.imaging.imageoptions.TiffOptions createTiffFrameOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); createTiffFrameOptions.setSource(new com.aspose.imaging.sources.StreamSource(new java.io.ByteArrayInputStream(new byte[0]))); createTiffFrameOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.MinIsBlack); createTiffFrameOptions.setBitsPerSample(new int[]{8}); // Create a grayscale copy of the active frame. // The pixel data is preserved but converted to the desired format. com.aspose.imaging.fileformats.tiff.TiffFrame grayscaleFrame = com.aspose.imaging.fileformats.tiff.TiffFrame.createFrameFrom(tiffImage.getActiveFrame(), createTiffFrameOptions); // Add the newly created frame to the TIFF image. tiffImage.addFrame(grayscaleFrame); tiffImage.save(); } finally { tiffImage.dispose(); }
public int getPlanarConfiguration()
Gets or sets the planar configuration.
public void setPlanarConfiguration(int value)
Gets or sets the planar configuration.
value
- The planar configuration.This example shows how to create a TIFF image from scratch and save it to a file.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions createOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 8 bits for each color component. createOptions.setBitsPerSample(new int[]{8, 8, 8}); // Set the Big Endian byte order (Motorola) createOptions.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.BigEndian); // Set the LZW compression. createOptions.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.Lzw); // Set the RGB color model. createOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); // All color components will be stored within a single plane. createOptions.setPlanarConfiguration(com.aspose.imaging.fileformats.tiff.enums.TiffPlanarConfigs.Contiguous); // Create a TIFF Frame of 100x100 px. // Note that you don't have to dispose a frame explicitly if it is included into TiffImage. // When the container is disposed all frames will be disposed automatically. com.aspose.imaging.fileformats.tiff.TiffFrame firstFrame = new com.aspose.imaging.fileformats.tiff.TiffFrame(createOptions, 100, 100); // Fill the entire frame with the blue-yellow gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(firstFrame.getWidth(), firstFrame.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(firstFrame); graphics.fillRectangle(gradientBrush, firstFrame.getBounds()); // Create a TIFF image. com.aspose.imaging.fileformats.tiff.TiffImage tiffImage = new com.aspose.imaging.fileformats.tiff.TiffImage(firstFrame); try { tiffImage.save(dir + "output.tif"); } finally { tiffImage.dispose(); }
public int getResolutionUnit()
Gets or sets the resolution unit.
public void setResolutionUnit(int value)
Gets or sets the resolution unit.
value
- The resolution unit.public long getRowsPerStrip()
Gets or sets the rows per strip.
public void setRowsPerStrip(long value)
Gets or sets the rows per strip.
value
- The rows per strip.public long getTileWidth()
Gets ot sets tile width.
public void setTileWidth(long value)
Gets ot sets tile width.
public long getTileLength()
Gets ot sets tile length.
public void setTileLength(long value)
Gets ot sets tile length.
public int[] getSampleFormat()
Gets or sets the sample format.
com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public void setSampleFormat(int[] value)
Gets or sets the sample format.
value
- The sample format.com.aspose.ms.System.ArgumentNullException
- valuecom.aspose.ms.System.ArgumentOutOfRangeException
- value;The array length must correspond to the samples per pixel count.public int getSamplesPerPixel()
Gets the samples per pixel. To change this property value use the BitsPerSample
property setter.
public long[] getSmaxSampleValue()
Gets or sets the max sample value. The value has a field type which best matches the sample data (Byte, Short or Long type).
public void setSmaxSampleValue(long[] value)
Gets or sets the max sample value. The value has a field type which best matches the sample data (Byte, Short or Long type).
value
- The max sample value.public long[] getSminSampleValue()
Gets or sets the min sample value. The value has a field type which best matches the sample data (Byte, Short or Long type).
public void setSminSampleValue(long[] value)
Gets or sets the min sample value. The value has a field type which best matches the sample data (Byte, Short or Long type).
value
- The min sample value.public String getSoftwareType()
Gets or sets the software type.
public void setSoftwareType(String value)
Gets or sets the software type.
value
- The software type.public long[] getStripByteCounts()
Gets or sets the strip byte counts.
public void setStripByteCounts(long[] value)
Gets or sets the strip byte counts.
value
- The strip byte counts.public long[] getStripOffsets()
Gets or sets the strip offsets.
public void setStripOffsets(long[] value)
Gets or sets the strip offsets.
value
- The strip offsets.public long[] getTileByteCounts()
Gets or sets the tile byte counts.
public void setTileByteCounts(long[] value)
Gets or sets the tile byte counts.
public long[] getTileOffsets()
Gets or sets the tile offsets.
public void setTileOffsets(long[] value)
Gets or sets the tile offsets.
public long getSubFileType()
Gets or sets a general indication of the kind of data contained in this subfile.
public void setSubFileType(long value)
Gets or sets a general indication of the kind of data contained in this subfile.
value
- The general indication of the kind of data contained in this subfile.public String getTargetPrinter()
Gets or sets the target printer.
public void setTargetPrinter(String value)
Gets or sets the target printer.
value
- The target printer.public int getThreshholding()
Gets or sets the threshholding.
public void setThreshholding(int value)
Gets or sets the threshholding.
value
- The threshholding.public int getTotalPages()
Gets the total pages.
public TiffRational getXposition()
Gets or sets the x position.
public void setXposition(TiffRational value)
Gets or sets the x position.
value
- The x position.public ResolutionSetting getResolutionSettings()
Gets or sets the resolution settings.
getResolutionSettings
in class ImageOptionsBase
public void setResolutionSettings(ResolutionSetting value)
Gets or sets the resolution settings.
setResolutionSettings
in class ImageOptionsBase
public TiffRational getXresolution()
Gets or sets the x resolution.
public void setXresolution(TiffRational value)
Gets or sets the x resolution.
value
- The x resolution.public TiffRational getYposition()
Gets or sets the y position.
public void setYposition(TiffRational value)
Gets or sets the y position.
value
- The y position.public TiffRational getYresolution()
Gets or sets the y resolution.
public void setYresolution(TiffRational value)
Gets or sets the y resolution.
value
- The y resolution.public long getFaxT4Options()
Gets or sets the fax t4 options.
public void setFaxT4Options(long value)
Gets or sets the fax t4 options.
value
- The fax t4 options.public int getPredictor()
Gets or sets the predictor for LZW compression.
public void setPredictor(int value)
Gets or sets the predictor for LZW compression.
value
- The predictor type.This example shows how to save a raster image to the TIFF format using various options.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.TiffOptions saveOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default); // Set 8 bits for each color component. saveOptions.setBitsPerSample(new int[]{8, 8, 8}); // Set the Big Endian byte order (Motorola) saveOptions.setByteOrder(com.aspose.imaging.fileformats.tiff.enums.TiffByteOrder.BigEndian); // Set the LZW compression. saveOptions.setCompression(com.aspose.imaging.fileformats.tiff.enums.TiffCompressions.Lzw); // Allow to reduce the size of continuous-tone images. // Currently this field is used only with LZW encoding because LZW is probably the only TIFF encoding scheme // that benefits significantly from a predictor step. saveOptions.setPredictor(com.aspose.imaging.fileformats.tiff.enums.TiffPredictor.Horizontal); // Set the RGB color model. saveOptions.setPhotometric(com.aspose.imaging.fileformats.tiff.enums.TiffPhotometrics.Rgb); // For YCbCr, you can use one of the following choices: // YCbCrSubSampling field JPEG sampling factors // ---------------------------------------------- // 1,1 1x1, 1x1, 1x1 // 2,1 2x1, 1x1, 1x1 // 2,2(default value) 2x2, 1x1, 1x1 // saveOptions.YCbCrSubsampling = new ushort[] { 2, 2 }; // All color components will be stored within a single plane. saveOptions.setPlanarConfiguration(com.aspose.imaging.fileformats.tiff.enums.TiffPlanarConfigs.Contiguous); // Create a TIFF Frame of 100x100 px. com.aspose.imaging.Image image = new com.aspose.imaging.fileformats.bmp.BmpImage(100, 100); try { // Fill the entire image with the blue-yellow gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(image.getWidth(), image.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image); graphics.fillRectangle(gradientBrush, image.getBounds()); image.save(dir + "output.tif", saveOptions); } finally { image.dispose(); }
public long getImageLength()
Gets or sets the image length.
public void setImageLength(long value)
Gets or sets the image length.
value
- The image length.public long getImageWidth()
Gets or sets the image width.
public void setImageWidth(long value)
Gets or sets the image width.
value
- The image width.public TiffExifIfd getExifIfd()
Gets or sets the pointer to EXIF IFD.
public TiffDataType[] getTags()
Gets or sets the tags.
public void setTags(TiffDataType[] value)
Gets or sets the tags.
value
- The tags.public int getValidTagCount()
Gets the valid tag count. This is not the total tags count but the number of tags which may be preserved.
public int getBitsPerPixel()
Gets the bits per pixel.
public boolean removeTag(int tag)
Removes the tag.
tag
- The tag to remove.public void validate()
Validates if options have valid combination of tags
public void addTags(TiffDataType[] tagsToAdd)
Adds the tags.
tagsToAdd
- The tags to add.public void addTag(TiffDataType tagToAdd)
Adds a new tag.
tagToAdd
- The tag to add.public TiffDataType getTagByType(int tagKey)
Gets the instance of the tag by type.
tagKey
- The tag key.