public final class DjvuImage extends RasterCachedMultipageImage
DjvuDocument class
This example shows how to load a DJVU image from a file stream.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
// Save each page as an individual PNG image.
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
// Generate a file name based on the page number.
String fileName = String.format("sample.%s.png", djvuPage.getPageNumber());
djvuPage.save(dir + fileName, new com.aspose.imaging.imageoptions.PngOptions());
}
} finally {
djvuImage.dispose();
stream.close();
}
| Modifier and Type | Field and Description |
|---|---|
com.aspose.ms.lang.Event<com.aspose.ms.System.ComponentModel.PropertyChangedEventHandler> |
PropertyChanged |
| Constructor and Description |
|---|
DjvuImage(InputStream stream)
Initializes a new instance of the
DjvuImage class. |
DjvuImage(InputStream stream,
LoadOptions loadOptions)
Initializes a new instance of the
DjvuImage class. |
DjvuImage(com.aspose.ms.System.IO.Stream stream,
LoadOptions loadOptions)
Initializes a new instance of the
DjvuImage class. |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustBrightness(int brightness)
Adjust of a
brightness for image. |
void |
adjustContrast(float contrast)
Image contrasting |
void |
adjustGamma(float gamma)
Gamma-correction of an image.
|
void |
adjustGamma(float gammaRed,
float gammaGreen,
float gammaBlue)
Gamma-correction of an image.
|
void |
binarizeBradley(double brightnessDifference,
int windowSize)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
|
void |
binarizeFixed(byte threshold)
Binarization of an image with predefined threshold
|
void |
binarizeOtsu()
Binarization of an image with Otsu thresholding
|
void |
cacheData()
Caches the data private.
|
void |
crop(int leftShift,
int rightShift,
int topShift,
int bottomShift)
Crop image with shifts.
|
void |
crop(Rectangle rectangle)
Cropping the image.
|
void |
dither(int ditheringMethod,
int bitsCount,
IColorPalette customPalette)
Performs dithering on the current image.
|
void |
filter(Rectangle rectangle,
FilterOptionsBase options)
Filters the specified rectangle.
|
DjvuPage |
getActivePage()
Gets or sets the currently active page
|
Image |
getDefaultPage()
Gets the default page.
|
DjvuPage[] |
getDjvuPages()
Gets the pages for the document
|
long |
getFileFormat()
Gets a value of file format
|
DjvuPage |
getFirstPage()
Gets the first page of the document
|
int |
getIdentifier()
Gets the unique identifier for the document
|
DjvuPage |
getLastPage()
Gets the last page of the document
|
DjvuPage |
getNextPage()
Gets the next page of the document
|
int |
getPageCount()
Gets the page count.
|
Image[] |
getPages()
Gets the pages.
|
DjvuPage |
getPreviousPage()
Gets the previous page of the document
|
void |
grayscale()
Transformation of an image to its grayscale representation
|
boolean |
hasAlpha()
Gets the Has alpha channel.
|
static DjvuImage |
loadDocument(InputStream stream)
Loads the document.
|
static DjvuImage |
loadDocument(InputStream stream,
LoadOptions loadOptions)
Loads the document.
|
void |
resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image.
|
void |
resize(int newWidth,
int newHeight,
int resizeType)
Resizes the image.
|
void |
resizeHeightProportionally(int newHeight,
int resizeType)
Resizes the width proportionally.
|
void |
resizeWidthProportionally(int newWidth,
int resizeType)
Resizes the width proportionally.
|
void |
rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
!:RasterCahcedMultipageImage.Rotate image around the center. |
void |
rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the Active frame only.
|
void |
setActivePage(DjvuPage value)
Gets or sets the currently active page
|
binarizeBradley, getBackgroundColor, getBitsPerPixel, getHeight, getImageOpacity, getPageExportingAction, getWidth, getXmpData, hasTransparentColor, isCached, normalizeAngle, replaceColor, replaceNonTransparentColors, rotateFlipAll, setBackgroundColor, setPageExportingAction, setXmpDatadither, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getHorizontalResolution, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataFormat, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, getVerticalResolution, isRawDataAvailable, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setHorizontalResolution, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, setVerticalResolution, toBitmap, writeArgb32ScanLine, writeScanLinecanLoad, canLoad, canLoad, canLoad, canSave, create, 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, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, save, saveclose, dispose, getDisposedpublic final com.aspose.ms.lang.Event<com.aspose.ms.System.ComponentModel.PropertyChangedEventHandler> PropertyChanged
public DjvuImage(InputStream stream)
Initializes a new instance of the DjvuImage class.
stream - The stream.DjvuImageException - Stream is emptyThis example shows how to load a DJVU image from a file stream.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
// Save each page as an individual PNG image.
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
// Generate a file name based on the page number.
String fileName = String.format("sample.%s.png", djvuPage.getPageNumber());
djvuPage.save(dir + fileName, new com.aspose.imaging.imageoptions.PngOptions());
}
} finally {
djvuImage.dispose();
stream.close();
}
public DjvuImage(InputStream stream, LoadOptions loadOptions)
Initializes a new instance of the DjvuImage class.
stream - The stream to load from.loadOptions - The load options.DjvuImageException - Stream is emptyThis example shows how to load a DJVU image from a file stream to stay within the specified memory limit.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
try {
// The max allowed size for all internal buffers is 1MB.
com.aspose.imaging.LoadOptions loadOptions = new com.aspose.imaging.LoadOptions();
loadOptions.setBufferSizeHint(1 * 1024 * 1024);
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream, loadOptions);
try {
// Save each page as an individual PNG image.
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
// Generate a file name based on the page number.
String fileName = String.format("sample.%s.png", djvuPage.getPageNumber());
djvuPage.save(dir + fileName, new com.aspose.imaging.imageoptions.PngOptions());
}
} finally {
djvuImage.dispose();
}
} finally {
stream.close();
}
public DjvuImage(com.aspose.ms.System.IO.Stream stream,
LoadOptions loadOptions)
Initializes a new instance of the DjvuImage class.
stream - The stream.loadOptions - The load options.public int getIdentifier()
Gets the unique identifier for the document
public int getPageCount()
Gets the page count.
Value: The page count.<autogeneratedoc></autogeneratedoc>getPageCount in interface IMultipageImagegetPageCount in class RasterCachedMultipageImagepublic Image[] getPages()
Gets the pages.
Value: The pages.<autogeneratedoc></autogeneratedoc>getPages in interface IMultipageImagegetPages in class RasterCachedMultipageImageThis example shows how to load a DJVU image from a file stream.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
// Save each page as an individual PNG image.
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
// Generate a file name based on the page number.
String fileName = String.format("sample.%s.png", djvuPage.getPageNumber());
djvuPage.save(dir + fileName, new com.aspose.imaging.imageoptions.PngOptions());
}
} finally {
djvuImage.dispose();
stream.close();
}
public final DjvuPage[] getDjvuPages()
Gets the pages for the document
Value: The pages.public Image getDefaultPage()
Gets the default page.
Value: The default page.<autogeneratedoc></autogeneratedoc>getDefaultPage in interface IMultipageImagegetDefaultPage in class RasterCachedMultipageImagepublic DjvuPage getActivePage()
Gets or sets the currently active page
DjvuImageException - There is no active page selected.This example shows how to load a DJVU image from a file stream and print information about the pages.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.FileInputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
System.out.println("The total number of pages: " + djvuImage.getPages().length);
System.out.println("The active page number: " + djvuImage.getActivePage().getPageNumber());
System.out.println("The first page number: " + djvuImage.getFirstPage().getPageNumber());
System.out.println("The last page number: " + djvuImage.getLastPage().getPageNumber());
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
System.out.println("--------------------------------------------------");
System.out.println("Page number: " + djvuPage.getPageNumber());
System.out.println("Page size: " + djvuPage.getSize());
System.out.println("Page raw format: " + djvuPage.getRawDataFormat());
}
} finally {
djvuImage.dispose();
}
} finally {
stream.close();
}
//The output may look like this:
//The total number of pages: 2
//The active page number: 1
//The first page number: 1
//The last page number: 2
//--------------------------------------------------
//Page number: 1
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
//--------------------------------------------------
//Page number: 2
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
public void setActivePage(DjvuPage value)
Gets or sets the currently active page
value - The active page.DjvuImageException - When the active page cannot be set as it belongs to another image.public DjvuPage getFirstPage()
Gets the first page of the document
DjvuImageException - The first page can not be foundThis example shows how to load a DJVU image from a file stream and print information about the pages.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.FileInputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
System.out.println("The total number of pages: " + djvuImage.getPages().length);
System.out.println("The active page number: " + djvuImage.getActivePage().getPageNumber());
System.out.println("The first page number: " + djvuImage.getFirstPage().getPageNumber());
System.out.println("The last page number: " + djvuImage.getLastPage().getPageNumber());
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
System.out.println("--------------------------------------------------");
System.out.println("Page number: " + djvuPage.getPageNumber());
System.out.println("Page size: " + djvuPage.getSize());
System.out.println("Page raw format: " + djvuPage.getRawDataFormat());
}
} finally {
djvuImage.dispose();
}
} finally {
stream.close();
}
//The output may look like this:
//The total number of pages: 2
//The active page number: 1
//The first page number: 1
//The last page number: 2
//--------------------------------------------------
//Page number: 1
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
//--------------------------------------------------
//Page number: 2
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
public DjvuPage getLastPage()
Gets the last page of the document
DjvuImageException - The last page can not be foundThis example shows how to load a DJVU image from a file stream and print information about the pages.
String dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
java.io.FileInputStream stream = new java.io.FileInputStream(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = new com.aspose.imaging.fileformats.djvu.DjvuImage(stream);
try {
System.out.println("The total number of pages: " + djvuImage.getPages().length);
System.out.println("The active page number: " + djvuImage.getActivePage().getPageNumber());
System.out.println("The first page number: " + djvuImage.getFirstPage().getPageNumber());
System.out.println("The last page number: " + djvuImage.getLastPage().getPageNumber());
for (com.aspose.imaging.fileformats.djvu.DjvuPage djvuPage : djvuImage.getPages()) {
System.out.println("--------------------------------------------------");
System.out.println("Page number: " + djvuPage.getPageNumber());
System.out.println("Page size: " + djvuPage.getSize());
System.out.println("Page raw format: " + djvuPage.getRawDataFormat());
}
} finally {
djvuImage.dispose();
}
} finally {
stream.close();
}
//The output may look like this:
//The total number of pages: 2
//The active page number: 1
//The first page number: 1
//The last page number: 2
//--------------------------------------------------
//Page number: 1
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
//--------------------------------------------------
//Page number: 2
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
public DjvuPage getNextPage()
Gets the next page of the document
DjvuImageException - The next page can not be foundpublic DjvuPage getPreviousPage()
Gets the previous page of the document
DjvuImageException - The previous page can not be foundpublic long getFileFormat()
Gets a value of file format
getFileFormat in class Imagepublic boolean hasAlpha()
Gets the Has alpha channel.
Value: The Has alpha channel.<autogeneratedoc></autogeneratedoc>hasAlpha in class RasterCachedMultipageImagepublic static DjvuImage loadDocument(InputStream stream)
Loads the document.
stream - The stream.public static DjvuImage loadDocument(InputStream stream, LoadOptions loadOptions)
Loads the document.
stream - The stream.loadOptions - The load options.public void rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
!:RasterCahcedMultipageImage.Rotate image around the center.
rotate in class RasterCachedMultipageImageangle - The rotate angle in degrees. Positive values will rotate clockwise.resizeProportionally - if set to true you will have your image size changed
according to rotated rectangle (corner points) projections in other
case that leaves dimensions untouched and only
image contents are rotated.backgroundColor - Color of the background.public void resize(int newWidth,
int newHeight,
int resizeType)
Resizes the image.
resize in class RasterCachedMultipageImagenewWidth - The new width.newHeight - The new height.resizeType - The resize type.This example loads a DJVU image and resizes it using various resizing methods.
String dir = "c:\\temp\\";
com.aspose.imaging.fileformats.djvu.DjvuImage image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Nearest Neighbour resampling.
image.resize(image.getWidth() * 2, image.getHeight() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Nearest Neighbour resampling.
image.resize(image.getWidth() / 2, image.getHeight() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Bilinear resampling.
image.resize(image.getWidth() * 2, image.getHeight() * 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Bilinear resampling.
image.resize(image.getWidth() / 2, image.getHeight() / 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void resizeWidthProportionally(int newWidth,
int resizeType)
Resizes the width proportionally.
resizeWidthProportionally in class RasterCachedMultipageImagenewWidth - The new width.resizeType - Type of the resize.This example loads a DJVU image and resizes it proportionally using various resizing methods. Only the width is specified, the height is calculated automatically.
String dir = "c:\\temp\\";
com.aspose.imaging.fileformats.djvu.DjvuImage image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Nearest Neighbour resampling.
image.resizeWidthProportionally(image.getWidth() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Nearest Neighbour resampling.
image.resizeWidthProportionally(image.getWidth() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Bilinear resampling.
image.resizeWidthProportionally(image.getWidth() * 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Bilinear resampling.
image.resizeWidthProportionally(image.getWidth() / 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void resizeHeightProportionally(int newHeight,
int resizeType)
Resizes the width proportionally.
resizeHeightProportionally in class RasterCachedMultipageImagenewHeight - The new height.resizeType - Type of the resize.This example loads a DJVU image and resizes it proportionally using various resizing methods. Only the height is specified, the width is calculated automatically.
String dir = "c:\\temp\\";
com.aspose.imaging.fileformats.djvu.DjvuImage image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Nearest Neighbour resampling.
image.resizeHeightProportionally(image.getHeight() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Nearest Neighbour resampling.
image.resizeHeightProportionally(image.getHeight() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale up by 2 times using Bilinear resampling.
image.resizeHeightProportionally(image.getHeight() * 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// Scale down by 2 times using Bilinear resampling.
image.resizeHeightProportionally(image.getHeight() / 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the Active frame only.
rotateFlip in class RasterCachedMultipageImagerotateFlipType - The rotate flip type.RotateFlipTypeThis example loads a DJVU image, rotates it by 90 degrees clockwise and optionally flips the image horizontally and(or) vertically.
String dir = "c:\\temp\\";
int[] rotateFlipTypes = new int[]
{
com.aspose.imaging.RotateFlipType.Rotate90FlipNone,
com.aspose.imaging.RotateFlipType.Rotate90FlipX,
com.aspose.imaging.RotateFlipType.Rotate90FlipXY,
com.aspose.imaging.RotateFlipType.Rotate90FlipY,
};
for (int rotateFlipType : rotateFlipTypes) {
// Rotate, flip and save to the output file.
com.aspose.imaging.fileformats.djvu.DjvuImage image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
image.rotateFlip(rotateFlipType);
image.save(dir + "sample." + rotateFlipType + ".png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
}
public void dither(int ditheringMethod,
int bitsCount,
IColorPalette customPalette)
Performs dithering on the current image.
dither in class RasterCachedMultipageImageditheringMethod - The dithering method.bitsCount - The final bits count for dithering.customPalette - The custom palette for dithering.The following example loads a DJVU image and performs threshold and floyd dithering using different palette depth.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage dicomImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Perform threshold dithering using 4-bit color palette which contains 16 colors.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
dicomImage.dither(com.aspose.imaging.DitheringMethod.ThresholdDithering, 4, null);
dicomImage.save(dir + "sample.ThresholdDithering4.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage dicomImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
dicomImage.dither(com.aspose.imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
dicomImage.save(dir + "sample.FloydSteinbergDithering1.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void crop(Rectangle rectangle)
Cropping the image.
crop in class RasterCachedMultipageImagerectangle - The rectangle.The following example crops a DJVU image. The cropping area is be specified via Aspose.Imaging.Rectangle.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Crop the image. The cropping area is the rectangular central area of the image.
com.aspose.imaging.Rectangle area = new com.aspose.imaging.Rectangle(
djvuImage.getWidth() / 4, djvuImage.getHeight() / 4, djvuImage.getWidth() / 2, djvuImage.getHeight() / 2);
djvuImage.crop(area);
// Save the cropped image to PNG
djvuImage.save(dir + "sample.Crop.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void crop(int leftShift,
int rightShift,
int topShift,
int bottomShift)
Crop image with shifts.
crop in class RasterCachedMultipageImageleftShift - The left shift.rightShift - The right shift.topShift - The top shift.bottomShift - The bottom shift.public void binarizeFixed(byte threshold)
Binarization of an image with predefined threshold
binarizeFixed in class RasterCachedMultipageImagethreshold - Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of
255 will be assigned to it, 0 otherwise.The following example binarizes a DJVU image with the predefined threshold. Binarized images contain only 2 colors - black and white.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Binarize the image with a threshold value of 127.
// If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
djvuImage.binarizeFixed((byte) 127);
djvuImage.save(dir + "sample.BinarizeFixed.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void binarizeOtsu()
Binarization of an image with Otsu thresholding
binarizeOtsu in class RasterCachedMultipageImageThe following example binarizes a DJVU image with Otsu thresholding. Binarized images contain only 2 colors - black and white.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Binarize the image with Otsu thresholding.
djvuImage.binarizeOtsu();
djvuImage.save(dir + "sample.BinarizeOtsu.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void binarizeBradley(double brightnessDifference,
int windowSize)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
binarizeBradley in class RasterCachedMultipageImagebrightnessDifference - The brightness difference between pixel and the average of an s x s window of pixels
centered around this pixel.windowSize - The size of s x s window of pixels centered around this pixelThe following example binarizes a DJVU image with Bradley's adaptive thresholding algorithm with the specified window size. Binarized images contain only 2 colors - black and white.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Binarize the image with a brightness difference of 5. The brightness is a difference between a pixel and the average of an 10 x 10 window of pixels centered around this pixel.
djvuImage.binarizeBradley(5, 10);
djvuImage.save(dir + "sample.BinarizeBradley5_10x10.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void grayscale()
Transformation of an image to its grayscale representation
grayscale in class RasterCachedMultipageImageThe following example transforms a colored DJVU image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
djvuImage.grayscale();
djvuImage.save(dir + "sample.Grayscale.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void adjustGamma(float gamma)
Gamma-correction of an image.
adjustGamma in class RasterCachedMultipageImagegamma - Gamma for red, green and blue channels coefficientThe following example performs gamma-correction of a DJVU image.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Set gamma coefficient for red, green and blue channels.
djvuImage.adjustGamma(2.5f);
djvuImage.save(dir + "sample.AdjustGamma.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void adjustGamma(float gammaRed,
float gammaGreen,
float gammaBlue)
Gamma-correction of an image.
adjustGamma in class RasterCachedMultipageImagegammaRed - Gamma for red channel coefficientgammaGreen - Gamma for green channel coefficientgammaBlue - Gamma for blue channel coefficientThe following example performs gamma-correction of a DJVU image applying different coefficients for color components.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Set individual gamma coefficients for red, green and blue channels.
djvuImage.adjustGamma(1.5f, 2.5f, 3.5f);
djvuImage.save(dir + "sample.AdjustGamma.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void adjustBrightness(int brightness)
Adjust of a brightness for image.
adjustBrightness in class RasterCachedMultipageImagebrightness - Brightness value.The following example performs brightness correction of a DJVU image.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
djvuImage.adjustBrightness(50);
djvuImage.save(dir + "sample.AdjustBrightness.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void adjustContrast(float contrast)
Image contrasting
adjustContrast in class RasterCachedMultipageImagecontrast - Contrast value (in range [-100; 100])The following example performs contrast correction of a DJVU image.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
djvuImage.adjustContrast(50f);
djvuImage.save(dir + "sample.AdjustContrast.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void filter(Rectangle rectangle, FilterOptionsBase options)
Filters the specified rectangle.
filter in class RasterCachedMultipageImagerectangle - The rectangle.options - The options.The following example applies various types of filters to a DJVU image.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a median filter with a rectangle size of 5 to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MedianFilterOptions(5));
djvuImage.save(dir + "sample.MedianFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.BilateralSmoothingFilterOptions(5));
djvuImage.save(dir + "sample.BilateralSmoothingFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussianBlurFilterOptions(5, 4.0));
djvuImage.save(dir + "sample.GaussianBlurFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussWienerFilterOptions(5, 4.0));
djvuImage.save(dir + "sample.GaussWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MotionWienerFilterOptions(10, 1.0, 90.0));
djvuImage.save(dir + "sample.MotionWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
djvuImage.filter(djvuImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.SharpenFilterOptions(5, 4.0));
djvuImage.save(dir + "sample.SharpenFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resizes the image.
resize in class RasterCachedMultipageImagenewWidth - The new width.newHeight - The new height.settings - The resize settings.This example loads a DJVU image and resizes it using various resizing settings.
String dir = "c:\\temp\\";
com.aspose.imaging.ImageResizeSettings resizeSettings = new com.aspose.imaging.ImageResizeSettings();
// The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
resizeSettings.setMode(com.aspose.imaging.ResizeType.AdaptiveResample);
// The small rectangular filter
resizeSettings.setFilterType(com.aspose.imaging.ImageFilterType.SmallRectangular);
// The number of colors in the palette.
resizeSettings.setEntriesCount(256);
// The color quantization is not used
resizeSettings.setColorQuantizationMethod(com.aspose.imaging.ColorQuantizationMethod.None);
// The euclidian method
resizeSettings.setColorCompareMethod(com.aspose.imaging.ColorCompareMethod.Euclidian);
com.aspose.imaging.Image image = (com.aspose.imaging.Image) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
com.aspose.imaging.fileformats.djvu.DjvuImage djvuImage = (com.aspose.imaging.fileformats.djvu.DjvuImage) image;
// Scale down by 2 times using adaptive resampling.
djvuImage.resize(image.getWidth() / 2, image.getHeight() / 2, resizeSettings);
// Save to PNG
djvuImage.save(dir + "downsample.adaptive.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void cacheData()
Caches the data private.
cacheData in class RasterCachedMultipageImageThe following example shows how to cache all pages of a DJVU image.
String dir = "c:\\temp\\";
// Load an image from a DJVU file.
com.aspose.imaging.fileformats.djvu.DjvuImage image = (com.aspose.imaging.fileformats.djvu.DjvuImage) com.aspose.imaging.Image.load(dir + "sample.djvu");
try {
// This call caches all the pages so that no additional data loading will be performed from the underlying data stream.
image.cacheData();
// Or you can cache the pages individually.
for (com.aspose.imaging.fileformats.djvu.DjvuPage page : image.getPages()) {
page.cacheData();
}
} finally {
image.dispose();
}