Class DjvuImage
- Namespace
- Aspose.Imaging.FileFormats.Djvu
- Assembly
- Aspose.Imaging.dll
DjVu document class supports graphics file format and facilitates seamless management of scanned documents and books, integrating text, drawings, images, and photos into a single format. Supporting multi-page operations, you can efficiently access unique document identifiers, count pages, set active pages, and retrieve specific document pages. With features for resizing, rotating, dithering, cropping, grayscale transformation, gamma corrections, adjustments, and filters application, this class empowers precise manipulation and enhancement of DjVu images to meet diverse application needs with ease and precision.
public sealed class DjvuImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImage, INotifyPropertyChanged
- Inheritance
-
DjvuImage
- Implements
- Inherited Members
Constructors
DjvuImage(Stream)
Start working with DjVu images by initializing a new instance of the DjvuImage class using a Stream parameter. Perfect for developers who want seamless integration of DjVu image processing into their projects.
public DjvuImage(Stream stream)
Parameters
stream
StreamThe stream.
Exceptions
- DjvuImageException
Stream is empty
DjvuImage(Stream, LoadOptions)
Start working with DjVu images seamlessly with this constructor, which initializes a new DjvuImage class instance using a Stream and LoadOptions parameters. Perfect for developers who want precise control over DjVu image loading options while maintaining simplicity and efficiency.
public DjvuImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
StreamThe stream to load from.
loadOptions
LoadOptionsThe load options.
Exceptions
- DjvuImageException
Stream is empty
Properties
ActivePage
Navigate through your DjVu document by accessing or setting the currently active page using this property. Seamlessly switch between pages to focus on specific content and enhance your document viewing experience.
public DjvuPage ActivePage { get; set; }
Property Value
- DjvuPage
The active page.
Exceptions
- DjvuImageException
There is no active page selected.
DjvuPages
Quickly retrieve all the pages contained within your DjVu document using this property. Simplify your document processing workflow by easily accessing and managing individual pages within your DjVu files. Improve efficiency and streamline your tasks with convenient page retrieval.
public DjvuPage[] DjvuPages { get; }
Property Value
- DjvuPage[]
The pages.
FileFormat
Obtain the file format information associated with your DjVu image file. Quickly determine the format of your file for seamless integration into your workflow.
public override FileFormat FileFormat { get; }
Property Value
FirstPage
Access the first page of your DjVu document with this property. Quickly retrieve the initial page to begin viewing or processing your document efficiently.
public DjvuPage FirstPage { get; }
Property Value
- DjvuPage
The first page.
Exceptions
- DjvuImageException
The first page can not be found
HasAlpha
Quickly determine whether your DjVu image file contains an alpha channel. Simplify your workflow by checking for the presence of transparency information in your images.
public override bool HasAlpha { get; }
Property Value
- bool
The Has alpha channel.
Identifier
Gets the unique identifier for the document
public int Identifier { get; }
Property Value
- int
The identifier.
LastPage
Retrieve the last page of your DjVu document using this property. Quickly access the final page for viewing or processing purposes with ease.
public DjvuPage LastPage { get; }
Property Value
- DjvuPage
The last page.
Exceptions
- DjvuImageException
The last page can not be found
NextPage
Navigate through your DjVu document by accessing the next page with this convenient property. Quickly move forward in your document viewing or processing tasks.
public DjvuPage NextPage { get; }
Property Value
- DjvuPage
The next page.
Exceptions
- DjvuImageException
The next page can not be found
PageCount
Retrieve the total number of pages in your DjVu image collection with this property. Ideal for quickly assessing the extent of your document or book stored in DjVu format. Improve your workflow efficiency with accurate page count information.
public override int PageCount { get; }
Property Value
- int
The page count.
Pages
Access the individual pages of your DjVu image collection with this property. Simplify navigation and manipulation of your document or book stored in DjVu format by accessing each page directly. Improve your workflow efficiency with easy page retrieval.
public override Image[] Pages { get; }
Property Value
- Image[]
The pages.
PreviousPage
Quickly move backward in your DjVu document viewing or processing tasks by accessing the previous page with this convenient property. Efficiently navigate through your document with ease.
public DjvuPage PreviousPage { get; }
Property Value
- DjvuPage
The previous page.
Exceptions
- DjvuImageException
The previous page can not be found
Methods
AdjustBrightness(int)
Adjust the brightness
of an image using a specified parameter,
providing control over luminance levels for optimal visual clarity. This method enhances
or diminishes the overall brightness of the image, allowing for fine adjustments to
achieve desired lighting effects. By modulating brightness, users can optimize image
visibility and enhance detail reproduction for improved viewing experience.
public override void AdjustBrightness(int brightness)
Parameters
brightness
intBrightness value.
AdjustContrast(float)
Enhance Image contrast to improve visual clarity and highlight details with this method, which adjusts the difference in brightness between light and dark areas. By fine-tuning contrast levels, users can achieve more vivid and impactful images, enhancing overall image quality and maximizing detail visibility. This adjustment helps to bring out subtle nuances in color and texture, resulting in more dynamic and visually appealing images.
public override void AdjustContrast(float contrast)
Parameters
contrast
floatContrast value (in range [-100; 100])
AdjustGamma(float)
Gamma correction, specifically for the red, green, and blue channels, involves adjusting the brightness of each color component separately. By applying different gamma coefficients to the RGB channels, you can fine-tune the overall brightness and contrast of an image. This technique ensures accurate color representation and improves the visual quality of the image across different display devices.
public override void AdjustGamma(float gamma)
Parameters
gamma
floatGamma for red, green and blue channels coefficient
AdjustGamma(float, float, float)
Gamma correction is applied to an image with customizable parameters for the red, green, and blue channels, allowing precise adjustment of color balance and brightness. This method enhances image quality by fine-tuning color representation, ensuring optimal rendering across different display devices. Adjusting gamma values for individual channels improves color balance and visual appeal.
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
floatGamma for red channel coefficient
gammaGreen
floatGamma for green channel coefficient
gammaBlue
floatGamma for blue channel coefficient
BinarizeBradley(double, int)
Binarization using Bradley's adaptive thresholding algorithm with integral image thresholding is a method that calculates a local threshold for each pixel based on a local neighborhood. It adapts to variations in illumination across the image, making it suitable for images with uneven lighting conditions. By computing the threshold using integral images, it efficiently handles large neighborhoods, making it applicable to real-time applications. This technique is commonly used in document processing, OCR (Optical Character Recognition), and image segmentation tasks where accurate binarization is essential for subsequent analysis.
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
doubleThe brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.
windowSize
intThe size of s x s window of pixels centered around this pixel
BinarizeFixed(byte)
Binarization with a predefined threshold simplifies complex images into binary representations, where pixels are categorized as either black or white based on their intensity compared to a specified threshold value. This technique is commonly used in image processing to enhance clarity, simplify analysis, and prepare images for further processing steps such as optical character recognition (OCR). By applying a fixed threshold, you can quickly transform grayscale images into binary form, making them easier to interpret and extract meaningful information from.
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byteThreshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
BinarizeOtsu()
Binarization using Otsu thresholding is a technique that automatically calculates an optimal threshold value based on the image's histogram. It separates the image into foreground and background by minimizing the intra-class variance. Otsu's method is widely used for segmenting images into binary form, particularly when the distribution of pixel intensities is bimodal or multimodal. This approach is beneficial for tasks such as object detection, image segmentation, and feature extraction, where accurate delineation between foreground and background is crucial.
public override void BinarizeOtsu()
CacheData()
Cache the data privately to optimize performance and reduce the need for repeated data retrieval from external sources. This approach also helps conserve resources, particularly in scenarios where data access is frequent or resources are limited.
public override void CacheData()
Crop(Rectangle)
"Crop" trims your image to focus on specific details or remove unwanted elements, enhancing its composition and visual impact. Whether you're adjusting photos for social media, creating website banners, or designing print materials, this tool helps you refine your images with precision and clarity.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
RectangleThe rectangle.
Crop(int, int, int, int)
Crop with shifts allows you to precisely adjust the position and dimensions of the cropped area within an image. This feature is invaluable for refining compositions, aligning elements, and emphasizing focal points in your visuals. By incorporating shifts into the cropping process, you can achieve pixel-perfect precision and fine-tune the framing of your images with ease.
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
intThe left shift.
rightShift
intThe right shift.
topShift
intThe top shift.
bottomShift
intThe bottom shift.
Dither(DitheringMethod, int, IColorPalette)
The "Dither" function applies a dithering effect to your image, enhancing its visual quality by reducing banding and improving color transitions. Whether you're working on digital art, photography, or graphic design projects, this feature adds a professional touch to your images, making them appear smoother and more refined.
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethodThe dithering method.
bitsCount
intThe final bits count for dithering.
customPalette
IColorPaletteThe custom palette for dithering.
Filter(Rectangle, FilterOptionsBase)
Apply filters to a specified rectangular area within the image to enhance or modify its appearance. By targeting specific regions, this method allows for precise adjustments, such as blurring, sharpening, or applying artistic effects, to achieve desired visual outcomes. Fine-tuning filters on selected areas empowers users to customize image aesthetics, improve clarity, and create artistic effects tailored to their preferences.
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
RectangleThe rectangle.
options
FilterOptionsBaseThe options.
Grayscale()
Grayscale transformation converts an image to a black-and-white representation, where each pixel's intensity is represented by a single value ranging from black to white. This process removes color information, resulting in a monochromatic image. Grayscale images are commonly used in applications where color is unnecessary or where simplicity is preferred, such as document scanning, printing, and certain types of image analysis.
public override void Grayscale()
LoadDocument(Stream)
Load your DjVu document with this method. Streamline your process by quickly accessing and importing your DjVu files into your application.
public static DjvuImage LoadDocument(Stream stream)
Parameters
stream
StreamThe stream.
Returns
- DjvuImage
Loaded djvu document
LoadDocument(Stream, LoadOptions)
Import your DjVu document by utilizing this method with stream and loadOptions parameters. Streamline your process by quickly accessing and importing DjVu files into your application, providing flexibility and customization options to meet your needs.
public static DjvuImage LoadDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
StreamThe stream.
loadOptions
LoadOptionsThe load options.
Returns
- DjvuImage
Loaded djvu document
ReleaseManagedResources()
protected override void ReleaseManagedResources()
Resize(int, int, ImageResizeSettings)
Resize the image to the specified width and height while applying additional settings as needed. This method enables users to adjust the dimensions of the image while maintaining desired attributes such as aspect ratio, image quality, and compression settings. By providing flexibility in resizing options, users can tailor the image to fit specific requirements and optimize its appearance for various applications and platforms.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
settings
ImageResizeSettingsThe resize settings.
Resize(int, int, ResizeType)
Resize the image using the Resize
method, providing a simple and effective way
to adjust the dimensions of your images according to your requirements. This
versatile functionality empowers you to easily scale images to your desired size,
enhancing their usability across various platforms and applications.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
intThe new width.
newHeight
intThe new height.
resizeType
ResizeTypeThe resize type.
ResizeHeightProportionally(int, ResizeType)
The ResizeHeightProportionally
method allows you to adjust the height of your
image while preserving its aspect ratio. This ensures that your image maintains
its proportions, preventing distortion and preserving its visual integrity.
Whether you're optimizing images for web pages, mobile apps, or print media, this
method ensures that your images look their best across different platforms and devices.
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
intThe new height.
resizeType
ResizeTypeType of the resize.
ResizeWidthProportionally(int, ResizeType)
The ResizeWidthProportionally
method offers a convenient solution to adjust the
width of your image while maintaining its aspect ratio. By proportionally resizing
the width, you can ensure that your images remain visually appealing and
consistent across different devices and screen sizes, enhancing their versatility
and usability in various contexts.
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
intThe new width.
resizeType
ResizeTypeType of the resize.
Rotate(float, bool, Color)
Rotate the image around its center with the Rotate method of the RasterCachedMultipageImage class. This convenient feature allows you to easily adjust the orientation of images while maintaining their center position, enhancing your image manipulation capabilities.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
floatThe rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionally
boolif 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 internal image contents are rotated.backgroundColor
ColorColor of the background.
RotateFlip(RotateFlipType)
The RotateFlip
method offers versatile manipulation options for your image, allowing
you to rotate, flip, or perform both operations on the active frame independently.
Whether you're editing photos, creating graphics, or enhancing digital art, this
method provides precise control over the orientation and composition of your images,
ensuring they meet your creative vision with ease and efficiency.
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipTypeThe rotate flip type.
SaveData(Stream)
protected override void SaveData(Stream stream)
Parameters
stream
Stream
UpdateDimensions(int, int)
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler PropertyChanged