public final class Jpeg2000Image extends RasterCachedImage
Jpeg2000 library main class
This example shows how to load a JPEG2000 image from a file and save it to PNG.
String dir = "c:\\temp\\"; // Load a JPEG2000 image. com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(dir + "sample.jp2"); try { // Save to PNG jpeg2000Image.save(dir + "sample.output.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { jpeg2000Image.dispose(); }
Constructor and Description |
---|
Jpeg2000Image(InputStream stream)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(InputStream stream,
int bitsPerPixel)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(int width,
int height)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(int width,
int height,
int bitsCount)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(int width,
int height,
Jpeg2000Options options)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(RasterImage image)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(RasterImage rasterImage,
int bitsPerPixel)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(String path)
Initializes a new instance of the
Jpeg2000Image class. |
Jpeg2000Image(String path,
int bitsPerPixel)
Initializes a new instance of the
Jpeg2000Image class. |
Modifier and Type | Method and Description |
---|---|
int |
getBitsPerPixel()
Gets image depth (bits per pixel)
|
int |
getCodec()
Gets the codec.
|
String[] |
getComments()
Gets or sets the comments.
|
long |
getFileFormat()
Gets a value of file format
|
int |
getHeight()
Gets the image height
|
double |
getHorizontalResolution()
Gets or sets the horizontal resolution, in pixels per inch, of this
RasterImage . |
PixelDataFormat |
getRawDataFormat()
Gets the raw data format.
|
int |
getRawLineSize()
Gets the raw line size in bytes.
|
double |
getVerticalResolution()
Gets or sets the vertical resolution, in pixels per inch, of this
RasterImage . |
int |
getWidth()
Gets the image width
|
XmpPacketWrapper |
getXmpData()
Gets or sets the XMP metadata.
|
void |
setComments(String[] value)
Gets or sets the comments.
|
void |
setHorizontalResolution(double value)
Gets or sets the horizontal resolution, in pixels per inch, of this
RasterImage . |
void |
setVerticalResolution(double value)
Gets or sets the vertical resolution, in pixels per inch, of this
RasterImage . |
void |
setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata.
|
adjustBrightness, adjustContrast, adjustGamma, adjustGamma, binarizeBradley, binarizeBradley, binarizeFixed, binarizeOtsu, cacheData, crop, dither, grayscale, isCached, resize, resize, rotate, rotateFlip
crop, dither, filter, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getImageOpacity, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, hasAlpha, hasTransparentColor, isRawDataAvailable, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceColor, replaceNonTransparentColors, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, toBitmap, writeArgb32ScanLine, writeScanLine
canLoad, canLoad, canLoad, canLoad, canSave, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette
getDataStreamContainer, save, save, save, save
close, dispose, getDisposed
public Jpeg2000Image(String path)
Initializes a new instance of the Jpeg2000Image
class.
path
- The path to load image from and initialize pixel and palette data with.This example shows how to load a JPEG2000 image from a file and save it to PNG.
String dir = "c:\\temp\\"; // Load a JPEG2000 image. com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(dir + "sample.jp2"); try { // Save to PNG jpeg2000Image.save(dir + "sample.output.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { jpeg2000Image.dispose(); }
public Jpeg2000Image(String path, int bitsPerPixel)
Initializes a new instance of the Jpeg2000Image
class.
path
- The path to load image from and initialize pixel and palette data withbitsPerPixel
- The bits per pixel.public Jpeg2000Image(InputStream stream)
Initializes a new instance of the Jpeg2000Image
class.
stream
- The stream to load image from and initialize pixel and palette data with.This example shows how to load a JPEG2000 image from a file stream and save it to PNG.
String dir = "c:\\temp\\"; // Load a JPEG2000 image from stream. java.io.FileInputStream stream = new java.io.FileInputStream(dir + "sample.jp2"); com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(stream); try { // Save to PNG jpeg2000Image.save(dir + "sample.output.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { jpeg2000Image.dispose(); stream.close(); }
public Jpeg2000Image(InputStream stream, int bitsPerPixel)
Initializes a new instance of the Jpeg2000Image
class.
stream
- The stream to load image from and initialize pixel and palette data with.bitsPerPixel
- The bits per pixel.public Jpeg2000Image(int width, int height)
Initializes a new instance of the Jpeg2000Image
class.
width
- The image widthheight
- The image heightThis example shows how to create a JPEG2000 image and save it to a file.
String dir = "c:\\temp\\"; // Create a JPEG2000 image of 100x100 px. com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpeg2000Image); // Fill the entire image in red. com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); graphics.fillRectangle(brush, jpeg2000Image.getBounds()); // Save to a file jpeg2000Image.save(dir + "sample.output.jp2", new com.aspose.imaging.imageoptions.Jpeg2000Options()); } finally { jpeg2000Image.dispose(); }
public Jpeg2000Image(int width, int height, Jpeg2000Options options)
Initializes a new instance of the Jpeg2000Image
class.
width
- The image widthheight
- The image heightoptions
- The options.This example shows how to create a JPEG2000 image with the desired options and save it to a file.
String dir = "c:\\temp\\"; com.aspose.imaging.imageoptions.Jpeg2000Options createOptions = new com.aspose.imaging.imageoptions.Jpeg2000Options(); // Use the irreversible Discrete Wavelet Transform 9-7 createOptions.setIrreversible(true); // JP2 is the "container" format for JPEG 2000 codestreams. // J2K is raw compressed data, without a wrapper. createOptions.setCodec(com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Codec.J2K); // Create a JPEG2000 image of 100x100 px. com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(100, 100, createOptions); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpeg2000Image); // Fill the entire image in red. com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); graphics.fillRectangle(brush, jpeg2000Image.getBounds()); // Save to a file jpeg2000Image.save(dir + "sample.output.j2k"); } finally { jpeg2000Image.dispose(); }
public Jpeg2000Image(int width, int height, int bitsCount)
Initializes a new instance of the Jpeg2000Image
class.
width
- The image widthheight
- The image heightbitsCount
- The bits count.public Jpeg2000Image(RasterImage image)
Initializes a new instance of the Jpeg2000Image
class.
image
- The image.This example shows how to create a JPEG2000 image with from another raster image.
String dir = "c:\\temp\\"; // Create a PNG image of 100x100 px. com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage); // Fill the entire image in red. com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed()); graphics.fillRectangle(brush, pngImage.getBounds()); // Create a JPEG2000 image based on the PNG image. com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = new com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image(pngImage); try { // Save to a file jpeg2000Image.save(dir + "output.jp2", new com.aspose.imaging.imageoptions.Jpeg2000Options()); } finally { jpeg2000Image.dispose(); } } finally { pngImage.dispose(); }
public Jpeg2000Image(RasterImage rasterImage, int bitsPerPixel)
Initializes a new instance of the Jpeg2000Image
class.
rasterImage
- The image to initialize pixel and palette data with.bitsPerPixel
- The bits per pixel.public XmpPacketWrapper getXmpData()
Gets or sets the XMP metadata.
getXmpData
in class RasterImage
public void setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata.
setXmpData
in class RasterImage
value
- The XMP metadata.public long getFileFormat()
Gets a value of file format
getFileFormat
in class Image
public PixelDataFormat getRawDataFormat()
Gets the raw data format.
getRawDataFormat
in class RasterImage
public int getRawLineSize()
Gets the raw line size in bytes.
getRawLineSize
in class RasterImage
public int getWidth()
Gets the image width
getWidth
in interface IObjectWithBounds
getWidth
in class Image
public int getHeight()
Gets the image height
getHeight
in interface IObjectWithBounds
getHeight
in class Image
public int getBitsPerPixel()
Gets image depth (bits per pixel)
getBitsPerPixel
in class Image
public double getHorizontalResolution()
Gets or sets the horizontal resolution, in pixels per inch, of this RasterImage
.
getHorizontalResolution
in class RasterImage
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
The following example shows how to set horizontal/vertical resolution of a JPEG2000 image.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.jp2"); try { com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = (com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image) image; // Get horizontal and vertical resolution of the Jpeg2000Image. double horizontalResolution = jpeg2000Image.getHorizontalResolution(); double verticalResolution = jpeg2000Image.getVerticalResolution(); System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution); System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution); if (horizontalResolution != 96.0 || verticalResolution != 96.0) { // Use the SetResolution method for updating both resolution values in a single call. System.out.println("Set resolution values to 96 dpi"); jpeg2000Image.setResolution(96.0, 96.0); System.out.println("The horizontal resolution, in pixels per inch: " + jpeg2000Image.getHorizontalResolution()); System.out.println("The vertical resolution, in pixels per inch: " + jpeg2000Image.getVerticalResolution()); } } finally { image.dispose(); } // The output may look like this: // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0 // Set resolution values to 96 dpi // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0
public void setHorizontalResolution(double value)
Gets or sets the horizontal resolution, in pixels per inch, of this RasterImage
.
setHorizontalResolution
in class RasterImage
value
- The horizontal resolution.
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
public double getVerticalResolution()
Gets or sets the vertical resolution, in pixels per inch, of this RasterImage
.
getVerticalResolution
in class RasterImage
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
The following example shows how to set horizontal/vertical resolution of a JPEG2000 image.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.jp2"); try { com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image jpeg2000Image = (com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Image) image; // Get horizontal and vertical resolution of the Jpeg2000Image. double horizontalResolution = jpeg2000Image.getHorizontalResolution(); double verticalResolution = jpeg2000Image.getVerticalResolution(); System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution); System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution); if (horizontalResolution != 96.0 || verticalResolution != 96.0) { // Use the SetResolution method for updating both resolution values in a single call. System.out.println("Set resolution values to 96 dpi"); jpeg2000Image.setResolution(96.0, 96.0); System.out.println("The horizontal resolution, in pixels per inch: " + jpeg2000Image.getHorizontalResolution()); System.out.println("The vertical resolution, in pixels per inch: " + jpeg2000Image.getVerticalResolution()); } } finally { image.dispose(); } // The output may look like this: // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0 // Set resolution values to 96 dpi // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0
public void setVerticalResolution(double value)
Gets or sets the vertical resolution, in pixels per inch, of this RasterImage
.
setVerticalResolution
in class RasterImage
value
- The vertical resolution.
Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.
public String[] getComments()
Gets or sets the comments.
public void setComments(String[] value)
Gets or sets the comments.
value
- The comments.public int getCodec()
Gets the codec.