Packages

 

com.aspose.imaging.fileformats.webp

Class WebPImage

    • Constructor Detail

      • WebPImage

        public WebPImage(InputStream stream)

        Initializes a new instance of the WebPImage class from stream.

        Parameters:
        stream - The stream WebP image.
      • WebPImage

        public WebPImage(InputStream stream,
                         LoadOptions loadOptions)

        Initializes a new instance of the WebPImage class from stream.

        Parameters:
        stream - The stream WebP image.
        loadOptions - The load options.
      • WebPImage

        public WebPImage(String path)

        Initializes a new instance of the WebPImage class from file.

        Parameters:
        path - The path to file WebP Image
      • WebPImage

        public WebPImage(String path,
                         LoadOptions loadOptions)

        Initializes a new instance of the WebPImage class from file.

        Parameters:
        path - The path to file WebP Image
        loadOptions - The load options.
      • WebPImage

        public WebPImage(RasterImage rasterImage)

        Initializes a new instance of the WebPImage class from rasterImage.

        Parameters:
        rasterImage - The raster image.
      • WebPImage

        public WebPImage(RasterImage rasterImage,
                         LoadOptions loadOptions)

        Initializes a new instance of the WebPImage class from rasterImage.

        Parameters:
        rasterImage - The raster image.
        loadOptions - The load options.
      • WebPImage

        public WebPImage(int width,
                         int height,
                         WebPOptions options)

        Initializes a new instance of the WebPImage class with empty image.

        Parameters:
        width - The image width
        height - The image height.
        options - The options.
      • WebPImage

        public WebPImage(int width,
                         int height,
                         WebPOptions options,
                         LoadOptions loadOptions)

        Initializes a new instance of the WebPImage class with empty image.

        Parameters:
        width - The image width
        height - The image height.
        options - The options.
        loadOptions - The load options.
    • Method Detail

      • getOptions

        public WebPOptions getOptions()

        Gets or sets the options.

        Returns:
        The options.
      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the image bits per pixel count.

        Specified by:
        getBitsPerPixel in class Image
        Returns:
        The image bits per pixel count.
      • getBlocks

        public IFrame[] getBlocks()

        Gets the Webp blocks.

        Returns:
        The blocks.
      • hasAlpha

        public boolean hasAlpha()

        Gets a value indicating whether this instance has alpha.

        Overrides:
        hasAlpha in class RasterImage
        Returns:
        true if this instance has alpha; otherwise, false.
      • getImageOpacity

        public float getImageOpacity()

        Gets opacity of this image.

        Overrides:
        getImageOpacity in class RasterImage
        Returns:
        The opacity value between 0.0 (fully transparent) and 1.0 (fully opaque).
      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
      • adjustBrightness

        public void adjustBrightness(int brightness)

        Adjust of a brightness for image.

        Overrides:
        adjustBrightness in class RasterCachedImage
        Parameters:
        brightness - Brightness value.
      • adjustContrast

        public void adjustContrast(float contrast)

        Image contrasting

        Overrides:
        adjustContrast in class RasterCachedImage
        Parameters:
        contrast - Contrast value (in range [-100; 100])
      • adjustGamma

        public void adjustGamma(float gammaRed,
                                float gammaGreen,
                                float gammaBlue)

        Gamma-correction of an image.

        Overrides:
        adjustGamma in class RasterCachedImage
        Parameters:
        gammaRed - Gamma for red channel coefficient
        gammaGreen - Gamma for green channel coefficient
        gammaBlue - Gamma for blue channel coefficient
      • adjustGamma

        public void adjustGamma(float gamma)

        Gamma-correction of an image.

        Overrides:
        adjustGamma in class RasterCachedImage
        Parameters:
        gamma - Gamma for red, green and blue channels coefficient
      • binarizeFixed

        public void binarizeFixed(byte threshold)

        Binarization of an image with predefined threshold

        Overrides:
        binarizeFixed in class RasterCachedImage
        Parameters:
        threshold - Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.
      • binarizeBradley

        public void binarizeBradley(double brightnessDifference,
                                    int windowSize)

        Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding

        Overrides:
        binarizeBradley in class RasterCachedImage
        Parameters:
        brightnessDifference - 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 pixel
      • crop

        public void crop(Rectangle rectangle)

        Cropping the image.

        Overrides:
        crop in class RasterCachedImage
        Parameters:
        rectangle - The rectangle.
      • dither

        public void dither(int ditheringMethod,
                           int bitsCount,
                           IColorPalette customPalette)

        Performs dithering on the current image.

        Overrides:
        dither in class RasterCachedImage
        Parameters:
        ditheringMethod - The dithering method.
        bitsCount - The final bits count for dithering.
        customPalette - The custom palette for dithering.
      • grayscale

        public void grayscale()

        Transformation of an image to its grayscale representation

        Overrides:
        grayscale in class RasterCachedImage
      • rotate

        public void rotate(float angle,
                           boolean resizeProportionally,
                           Color backgroundColor)

        WebPImage.Rotate image around the center.

        Overrides:
        rotate in class RasterCachedImage
        Parameters:
        angle - 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.
      • resize

        public void resize(int newWidth,
                           int newHeight,
                           int resizeType)

        Resizes the image.

        Overrides:
        resize in class RasterCachedImage
        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        resizeType - The resize type.
      • resize

        public void resize(int newWidth,
                           int newHeight,
                           ImageResizeSettings settings)

        Resizes the image.

        Overrides:
        resize in class RasterCachedImage
        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        settings - The resize settings.
      • addBlock

        public void addBlock(IFrame block)

        Adds a new Webp block.

        Parameters:
        block - The Webp block to add.
      • clearBlocks

        public void clearBlocks()

        Clears all the Webp blocks.

      • insertBlock

        public void insertBlock(int index,
                                IFrame block)

        Adds a new Webp block.

        Parameters:
        index - The zero-based element, at which block will be inserted.
        block - The Webp block to add.
      • removeBlock

        public void removeBlock(IFrame block)

        Removes the Webp block.

        Parameters:
        block - The block to remove.

        Note: do not forget to Dispose the block if you will not add it to some other WebPImage.

      • rotateFlipAll

        public void rotateFlipAll(int rotateFlip)

        Rotates the flip all frames in the image.

        Parameters:
        rotateFlip - The rotate flip type to perform.
      • filter

        public void filter(Rectangle rectangle,
                           FilterOptionsBase options)

        Filters the specified rectangle.

        Overrides:
        filter in class RasterImage
        Parameters:
        rectangle - The rectangle.
        options - The options.
      • replaceColor

        public void replaceColor(int oldColorArgb,
                                 byte oldColorDiff,
                                 int newColorArgb)

        Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

        Overrides:
        replaceColor in class RasterImage
        Parameters:
        oldColorArgb - Old color ARGB value to be replaced.
        oldColorDiff - Allowed difference in old color to be able to widen replaced color tone.
        newColorArgb - New color ARGB value to replace old color with.
      • replaceNonTransparentColors

        public void replaceNonTransparentColors(int newColorArgb)

        Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one.

        Overrides:
        replaceNonTransparentColors in class RasterImage
        Parameters:
        newColorArgb - New color ARGB value to replace non transparent colors with.