Packages

 

com.aspose.imaging.fileformats.png

Class PngImage

    • Constructor Detail

      • PngImage

        public PngImage(int width,
                        int height)

        Initializes a new instance of the PngImage class.

        Parameters:
        width - The width.
        height - The height.
      • PngImage

        public PngImage(String path)

        Initializes a new instance of the PngImage class.

        Parameters:
        path - The path to load an image.
      • PngImage

        public PngImage(RasterImage rasterImage)

        Initializes a new instance of the PngImage class.

        Parameters:
        rasterImage - The raster image.
      • PngImage

        public PngImage(String path,
                        int colorType)

        Initializes a new instance of the PngImage class.

        Parameters:
        path - The path to load an image.
        colorType - The color type.
        Throws:
        com.aspose.ms.System.ArgumentNullException - if path is null
      • PngImage

        public PngImage(RasterImage rasterImage,
                        int colorType)

        Initializes a new instance of the PngImage class.

        Parameters:
        rasterImage - The raster image.
        colorType - The color type.
      • PngImage

        public PngImage(InputStream stream)

        Initializes a new instance of the PngImage class.

        Parameters:
        stream - The stream to load an image.
      • PngImage

        public PngImage(int width,
                        int height,
                        int colorType)

        Initializes a new instance of the PngImage class.

        Parameters:
        width - The width.
        height - The height.
        colorType - The color type.
      • PngImage

        public PngImage(PngOptions pngOptions,
                        int width,
                        int height)

        Initializes a new instance of the PngImage class.

        Parameters:
        pngOptions - The png options.
        width - The width.
        height - The height.
    • Method Detail

      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the bits per pixel.

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

        public double getHorizontalResolution()

        Gets or sets the horizontal resolution.

        Overrides:
        getHorizontalResolution in class RasterImage
        Returns:
        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.

      • setHorizontalResolution

        public void setHorizontalResolution(double value)

        Gets or sets the horizontal resolution.

        Overrides:
        setHorizontalResolution in class RasterImage
        Parameters:
        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.

      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
      • getVerticalResolution

        public double getVerticalResolution()

        Gets or sets the vertical resolution.

        Overrides:
        getVerticalResolution in class RasterImage
        Returns:
        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.

      • setVerticalResolution

        public void setVerticalResolution(double value)

        Gets or sets the vertical resolution.

        Overrides:
        setVerticalResolution in class RasterImage
        Parameters:
        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.

      • hasTransparentColor

        public boolean hasTransparentColor()

        Gets a value indicating whether image has transparent color.

        Overrides:
        hasTransparentColor in class RasterImage
      • setTransparentColor

        public void setTransparentColor(boolean value)

        Gets a value indicating whether image has transparent color.

        Overrides:
        setTransparentColor in class RasterImage
      • hasAlpha

        public boolean hasAlpha()

        Get a value indicating whether this instance has alpha.

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

        public boolean hasBackgroundColor()

        Gets a value indicating whether has background color.

        Overrides:
        hasBackgroundColor in class Image
      • setBackgroundColor

        public void setBackgroundColor(boolean value)

        Gets a value indicating whether has background color.

        Overrides:
        setBackgroundColor in class Image
      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Gets the background color.

        Overrides:
        setBackgroundColor in class Image
      • getInterlaced

        public boolean getInterlaced()

        Gets a value indicating whether this PngImage is interlaced.

        Value: true if interlaced; otherwise, false.
      • setXmpData

        public void setXmpData(XmpPacketWrapper value)

        Gets or sets the XMP metadata.

        Value: The XMP metadata.
        Overrides:
        setXmpData in class RasterImage
        Parameters:
        value - The XMP metadata.
      • getOriginalOptions

        public ImageOptionsBase getOriginalOptions()

        Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the DataStreamSupporter.Save(string) method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Image.Save(string, ImageOptionsBase) method as the second parameter.

        Overrides:
        getOriginalOptions in class Image
        Returns:
        The options based on the original file settings.