Packages

 

com.aspose.imaging.fileformats.tiff

Class TiffImage

    • Constructor Detail

      • TiffImage

        public TiffImage(TiffFrame frame)

        Initializes a new instance of the TiffImage class.

        Parameters:
        frame - The tiff frame to initialize image with.
        Throws:
        com.aspose.ms.System.ArgumentNullException - Tiff frame cannot be empty.;frame
      • TiffImage

        public TiffImage(TiffFrame[] frames)

        Initializes a new instance of the TiffImage class.

        Parameters:
        frames - The frames.
        Throws:
        com.aspose.ms.System.ArgumentNullException - frames
    • Method Detail

      • 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.
      • hasTransparentColor

        public boolean hasTransparentColor()

        Gets a value indicating whether image has transparent color.

        Overrides:
        hasTransparentColor in class RasterImage
        Returns:
        a value indicating whether image has transparent color.
      • setTransparentColor

        public void setTransparentColor(boolean value)

        Gets a value indicating whether image has transparent color.

        Overrides:
        setTransparentColor in class RasterImage
        Parameters:
        value - a value indicating whether image has transparent color.
      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
        Returns:
        a value of file format
      • getPremultiplyComponents

        public boolean getPremultiplyComponents()

        Gets or sets a value indicating whether components must be premultiplied.

        Overrides:
        getPremultiplyComponents in class RasterImage
        Returns:
        true if components must be premultiplied; otherwise, false.
      • setPremultiplyComponents

        public void setPremultiplyComponents(boolean value)

        Gets or sets a value indicating whether components must be premultiplied.

        Overrides:
        setPremultiplyComponents in class RasterImage
        Parameters:
        value - true if components must be premultiplied; otherwise, false.
      • getByteOrder

        public int getByteOrder()

        Gets or sets a value indicating the tiff byte order.

        Returns:
        The tiff byte order.
      • setByteOrder

        public void setByteOrder(int value)

        Gets or sets a value indicating the tiff byte order.

        Parameters:
        value - The tiff byte order.
      • getHorizontalResolution

        public double getHorizontalResolution()

        Gets the horizontal resolution, in pixels per inch, of this Image.

        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 the horizontal resolution, in pixels per inch, of this Image.

        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.

      • getVerticalResolution

        public double getVerticalResolution()

        Gets the vertical resolution, in pixels per inch, of this Image.

        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 the vertical resolution, in pixels per inch, of this Image.

        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.

      • getBackgroundColor

        public Color getBackgroundColor()

        Gets or sets a value for the background color.

        Overrides:
        getBackgroundColor in class Image
      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Gets or sets a value for the background color.

        Overrides:
        setBackgroundColor in class Image
      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the image bits per pixel value of current frame.

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

        public TiffFrame getActiveFrame()

        Gets or sets the active frame.

        Returns:
        Active frame.
      • setActiveFrame

        public void setActiveFrame(TiffFrame value)

        Gets or sets the active frame.

        Parameters:
        value - Active frame.
      • getFrames

        public TiffFrame[] getFrames()

        Gets Frames array of the image.

      • isCached

        public final boolean isCached()

        Gets a value indicating whether object's data is cached currently and no data reading is required.

        Specified by:
        isCached in class DataStreamSupporter
        Returns:
        true if object's data is cached; otherwise, false.
      • getExifData

        public ExifData getExifData()

        Gets or sets EXIF data for the active frame.

      • setExifData

        public void setExifData(ExifData value)

        Gets or sets EXIF data for the active frame.

      • getImageOpacity

        public float getImageOpacity()

        Gets opacity of this image (active frame).

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

        public void setXmpData(XmpPacketWrapper value)

        Gets or sets XMP data from frame.

        Overrides:
        setXmpData in class RasterImage
        Parameters:
        value - XMP packet data wrapper
      • alignResolutions

        public void alignResolutions()

        Helper method to make horizontal and vertical resolutions equal.

      • dither

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

        Performs dithering on the current image.

        Specified by:
        dither in class RasterImage
        Parameters:
        ditheringMethod - The dithering method.
        bitsCount - The final bits count for dithering.
        customPalette - The custom palette for dithering.
      • setResolution

        public void setResolution(double dpiX,
                                  double dpiY)

        Sets the resolution for this RasterImage.

        Overrides:
        setResolution in class RasterImage
        Parameters:
        dpiX - The horizontal resolution, in dots per inch, of the RasterImage.
        dpiY - The vertical resolution, in dots per inch, of the RasterImage.
      • cacheData

        public final void cacheData()

        Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer.

        Specified by:
        cacheData in class DataStreamSupporter
      • rotateFlip

        public void rotateFlip(int rotateFlipType)

        Rotates, flips, or rotates and flips the Active frame only.

        Specified by:
        rotateFlip in class Image
        Parameters:
        rotateFlipType - The rotate flip type.
      • rotateFlipAll

        public void rotateFlipAll(int rotateFlip)

        Rotates the flip all frames in image.

        Parameters:
        rotateFlip - The rotate flip type.
      • rotate

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

        Rotate image around the center.

        Overrides:
        rotate in class RasterImage
        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 internal image contents are rotated.
        backgroundColor - Color of the background.
      • addFrame

        public void addFrame(TiffFrame frame)

        Adds the frame to image

        Parameters:
        frame - The frame to add.
      • add

        public void add(TiffImage image)

        Adds the specified image's frames to current frame.

        Parameters:
        image - The source image.
      • addFrames

        public void addFrames(TiffFrame[] frames)

        Adds the frames array to image

        Parameters:
        frames - The frames array to add
      • insertFrame

        public void insertFrame(int index,
                                TiffFrame frameToInsert)

        The insert frame.

        Parameters:
        index - Index of new frame in list of frames
        frameToInsert - The frame To Insert.
      • replaceFrame

        public final TiffFrame replaceFrame(int index,
                                            TiffFrame frameToReplace)

        Replaces the frame at the specified position.

        Parameters:
        index - The zero based frame position.
        frameToReplace - The frame to replace.


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

        Returns:
        The removed frame.
      • removeFrame

        public TiffFrame removeFrame(int index)

        Removes the frame by its index.

        Parameters:
        index - Index of frame to be removed.

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

        Returns:
        The removed frame.
      • removeFrame

        public void removeFrame(TiffFrame frame)

        Removes the specified frame.

        Parameters:
        frame - The frame to remove.

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

      • resize

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

        Resizes the image.

        Overrides:
        resize in class RasterImage
        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 RasterImage
        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        settings - The resize settings.
      • resizeWidthProportionally

        public void resizeWidthProportionally(int newWidth,
                                              int resizeType)

        Resizes the width proportionally.

        Overrides:
        resizeWidthProportionally in class Image
        Parameters:
        newWidth - The new width.
        resizeType - Type of the resize.
      • resizeHeightProportionally

        public void resizeHeightProportionally(int newHeight,
                                               int resizeType)

        Resizes the height proportionally.

        Overrides:
        resizeHeightProportionally in class Image
        Parameters:
        newHeight - The new height.
        resizeType - Type of the resize.
      • resizeProportional

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

        Performs proportional resize on the image. The proportional resize will resize each frame according to the ratio of newWidth/width and newHeight/height.

        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        resizeType - The resize type.
      • crop

        public void crop(Rectangle rectangle)

        Cropping the image.

        Overrides:
        crop in class RasterImage
        Parameters:
        rectangle - The rectangle.
      • grayscale

        public void grayscale()

        Transformation of an image to its grayscale representation

        Overrides:
        grayscale in class RasterImage
      • binarizeFixed

        public void binarizeFixed(byte threshold)

        Binarization of an image with predefined threshold

        Overrides:
        binarizeFixed in class RasterImage
        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.
      • binarizeOtsu

        public void binarizeOtsu()

        Binarization of an image with Otsu thresholding

        Overrides:
        binarizeOtsu in class RasterImage
      • 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 RasterImage
        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(int leftShift,
                         int rightShift,
                         int topShift,
                         int bottomShift)

        Crop image with shifts.

        Overrides:
        crop in class RasterImage
        Parameters:
        leftShift - The left shift.
        rightShift - The right shift.
        topShift - The top shift.
        bottomShift - The bottom shift.
      • adjustBrightness

        public void adjustBrightness(int brightness)

        Adjust of a brightness for image.

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

        public void adjustContrast(float contrast)

        Image contrasting

        Overrides:
        adjustContrast in class RasterImage
        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 RasterImage
        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 RasterImage
        Parameters:
        gamma - Gamma for red, green and blue channels coefficient
      • 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.