Packages

 

com.aspose.imaging.fileformats.tga

Class TgaImage

    • Constructor Detail

      • TgaImage

        public TgaImage(String path)

        Initializes a new instance of the TgaImage class.

        Parameters:
        path - The path to load an image.
        Throws:
        com.aspose.ms.System.ArgumentNullException - Specified path is null.
      • TgaImage

        public TgaImage(RasterImage rasterImage)

        Initializes a new instance of the TgaImage class.

        Parameters:
        rasterImage - The raster image.
      • TgaImage

        public TgaImage(InputStream stream)

        Initializes a new instance of the TgaImage class.

        Parameters:
        stream - The stream to load an image.
    • Method Detail

      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets bits per pixel.

        Specified by:
        getBitsPerPixel in class Image
        Returns:
        bits per pixel.
      • getBytesPerPixel

        public final int getBytesPerPixel()

        Gets bytes per pixel.

        Returns:
        bytes per pixel.
      • hasAlpha

        public boolean hasAlpha()

        Gets a value indicating whether this TgaImage has an alpha channel.

        Overrides:
        hasAlpha in class RasterImage
        Returns:
        a value indicating whether this TgaImage has an alpha channel.
      • isGrayScale

        public final boolean isGrayScale()

        Gets a value indicating whether this TgaImage is gray-scale.

        Returns:
        a value indicating whether this TgaImage is gray-scale.
      • getFileFormat

        public long getFileFormat()

        Gets the file format.

        Overrides:
        getFileFormat in class Image
        Returns:
        the file format.
        See Also:
        FileFormat
      • hasColorMap

        public final boolean hasColorMap()

        Gets a value indicating whether this image has color map.

        Returns:
        a value indicating whether this image has color map.
      • getGammaValueNumerator

        public final int getGammaValueNumerator()

        Gets Gamma Value Numerator part. An uncorrected image (an image with no gamma) should have the value 1.0 as the result.

        Returns:
        Gamma Value Numerator part.
      • getGammaValueDenominator

        public final int getGammaValueDenominator()

        Gets Gamma Value Denominator part. An uncorrected image (an image with no gamma) should have the value 1.0 as the result.

        Returns:
        Gamma Value Denominator part.
      • getPixelAspectRatioNumerator

        public final int getPixelAspectRatioNumerator()

        Gets Pixel Aspect Ratio numerator part.

        Returns:
        Pixel Aspect Ratio numerator part.
      • getPixelAspectRatioDenominator

        public final int getPixelAspectRatioDenominator()

        Gets Pixel Aspect Ratio denominator part.

        Returns:
        Pixel Aspect Ratio denominator part.
      • getXOrigin

        public final int getXOrigin()

        Gets absolute horizontal coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.g., the TARGA series).

        Returns:
        absolute horizontal coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.
      • setXOrigin

        public final void setXOrigin(int value)

        Sets absolute horizontal coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.g., the TARGA series).

        Parameters:
        value - absolute horizontal coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getYOrigin

        public final int getYOrigin()

        Gets absolute vertical coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.g., the TARGA series).

        Returns:
        absolute vertical coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.
      • setYOrigin

        public final void setYOrigin(int value)

        Sets absolute vertical coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.g., the TARGA series).

        Parameters:
        value - absolute vertical coordinate for the lower left corner of the image as it is positioned on a display device having an origin at the lower left of the screen(e.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getImageId

        public final String getImageId()

        Gets Image ID.

        This optional field contains identifying information about the image. The maximum length for this field is 255 bytes.

        Returns:
        Image ID.
      • setImageId

        public final void setImageId(String value)

        Sets Image ID.

        This optional field contains identifying information about the image. The maximum length for this field is 255 bytes.

        Parameters:
        value - Image ID.
      • getAuthorComments

        public final String getAuthorComments()

        Gets Author Comments. This is an ASCII field consisting of 324 bytes which are organized as four lines of 80 characters, each followed by a null terminator.

        Returns:
        Author Comments.
      • setAuthorComments

        public final void setAuthorComments(String value)

        Sets Author Comments. This is an ASCII field consisting of 324 bytes which are organized as four lines of 80 characters, each followed by a null terminator.

        Parameters:
        value - Author Comments.
      • getAuthorName

        public final String getAuthorName()

        Gets Author Name. This field is a total of 40 ASCII characters for the name. If the field is used, it should contain the name of the person who created the image (author).

        Returns:
        Author Name.
      • setAuthorName

        public final void setAuthorName(String value)

        Sets Author Name. This field is a total of 40 ASCII characters for the name. If the field is used, it should contain the name of the person who created the image (author).

        Parameters:
        value - Author Name.
      • getDateTimeStamp

        public final Date getDateTimeStamp()

        Gets Date/Time Stamp. This field defines the value for the date and time that the image was saved. Even though operating systems typically time- and date-stamp files, this feature is provided because the operating system may change the time and date stamp if the file is copied. By using this area, you are guaranteed an unmodified region for date and time recording.

        Returns:
        Date/Time Stamp.
      • setDateTimeStamp

        public final void setDateTimeStamp(Date value)

        Sets Date/Time Stamp. This field defines the value for the date and time that the image was saved. Even though operating systems typically time- and date-stamp files, this feature is provided because the operating system may change the time and date stamp if the file is copied. By using this area, you are guaranteed an unmodified region for date and time recording.

        Parameters:
        value - Date/Time Stamp.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getJobNameOrId

        public final String getJobNameOrId()

        Gets Job Name/ID.

        Returns:
        Job Name/ID.
      • setJobNameOrId

        public final void setJobNameOrId(String value)

        Sets Job Name/ID.

        Parameters:
        value - Job Name/ID.
      • getJobTime

        public final Date getJobTime()

        Gets Job Time.

        Returns:
        Job Time.
      • setJobTime

        public final void setJobTime(Date value)

        Sets Job Time.

        Parameters:
        value - Job Time.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getTransparentColor

        public Color getTransparentColor()

        Gets Key Color.

        The Key Color can be thought of as the ‘background color’ or ‘transparent color’. This is the color of the ‘non image’ area of the screen, and the same color that the screen would be cleared to if erased in the application.

        Overrides:
        getTransparentColor in class RasterImage
        Returns:
        Key Color.
      • setTransparentColor

        public void setTransparentColor(Color value)

        Sets Key Color.

        The Key Color can be thought of as the ‘background color’ or ‘transparent color’. This is the color of the ‘non image’ area of the screen, and the same color that the screen would be cleared to if erased in the application.

        Overrides:
        setTransparentColor in class RasterImage
        Parameters:
        value - Key Color.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • hasTransparentColor

        public boolean hasTransparentColor()

        Gets a value indicating whether the image has transparent color.

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

        public void setTransparentColor(boolean value)

        Sets a value indicating whether the image has transparent color.

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

        public Color getBackgroundColor()

        Gets the background color.

        Overrides:
        getBackgroundColor in class Image
        Returns:
        the background color.
      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Sets the background color.

        Overrides:
        setBackgroundColor in class Image
        Parameters:
        value - the background color.
      • hasBackgroundColor

        public boolean hasBackgroundColor()

        Gets a value indicating whether the image has background color.

        Overrides:
        hasBackgroundColor in class Image
        Returns:
        a value indicating whether the image has background color.
      • setBackgroundColor

        public void setBackgroundColor(boolean value)

        Sets a value indicating whether the image has background color.

        Overrides:
        setBackgroundColor in class Image
        Parameters:
        value - a value indicating whether the image has background color.
      • getSoftwareVersion

        public final String getSoftwareVersion()

        Gets Software Version. Accepted version string length is 3-4 characters.

        Returns:
        Software Version.
      • setSoftwareVersion

        public final void setSoftwareVersion(String value)

        Sets Software Version. Accepted version string length is 3-4 characters.

        Parameters:
        value - Software Version.
      • getSoftwareVersionLetter

        public final char getSoftwareVersionLetter()

        Gets Software Version letter part.

        Returns:
        Software Version letter part.
      • setSoftwareVersionLetter

        public final void setSoftwareVersionLetter(char value)

        Sets Software Version letter part.

        Parameters:
        value - Software Version letter part.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getSoftwareVersionNumber

        public final int getSoftwareVersionNumber()

        Gets Software Version number part.

        Returns:
        Software Version number part.
      • setSoftwareVersionNumber

        public final void setSoftwareVersionNumber(int value)

        Sets Software Version number part.

        Parameters:
        value - Software Version number part.
        Code example:

        Updating public properties of the loaded TGA image.


        try (TgaImage image = (TgaImage)Image.load("test.tga"))
        {
            image.setDateTimeStamp(new Date());
            image.setAuthorName("John Smith");
            image.setAuthorComments("Comment");
            image.setImageId("ImageId");
            image.setJobNameOrId("Important Job");
            image.setJobTime(new Date(0,0, 10));
            image.setTransparentColor(Color.fromArgb(123));
            image.setSoftwareId("SoftwareId");
            image.setSoftwareVersion("abc1");
            image.setSoftwareVersionLetter('a');
            image.setSoftwareVersionNumber(2);
            image.setXOrigin(1000);
            image.setYOrigin(1000);
        
            image.save("test.tga");
        }
        

      • getSoftwareId

        public final String getSoftwareId()

        Gets Software ID. A total of 40 ASCII characters for the Software ID.

        Returns:
        Software ID.
      • setSoftwareId

        public final void setSoftwareId(String value)

        Sets Software ID. A total of 40 ASCII characters for the Software ID.

        Parameters:
        value - Software ID.
      • op_Equality

        public static boolean op_Equality(TgaImage first,
                                          TgaImage second)

        Equality comparison.

        Parameters:
        first - First TgaImage that takes part in comparison.
        second - Second TgaImage that takes part in comparison.
        Returns:
        Comparison results.
      • op_Inequality

        public static boolean op_Inequality(TgaImage first,
                                            TgaImage second)

        Non-equality comparison.

        Parameters:
        first - First TgaImage that takes part in comparison.
        second - Second TgaImage that takes part in comparison.
        Returns:
        Comparison results.
      • deepClone

        public final TgaImage deepClone()

        Creates a new object that is a copy of the current instance.

        Returns:
        Returns a new object that is a copy of the current instance.
      • deepClone

        public final void deepClone(TgaImage tgaImage)

        Clone other TgaImage object's properties.

        Parameters:
        tgaImage - Other TgaImage
      • equals

        public final boolean equals(TgaImage other)

        Equality comparison.

        Parameters:
        other - Second TgaImage that takes part in comparison.
        Returns:
        Comparison results.
      • equals

        public boolean equals(Object other)

        Equality comparison.

        Overrides:
        equals in class Object
        Parameters:
        other - Second TgaImage that takes part in comparison.
        Returns:
        Comparison results.
      • hashCode

        public int hashCode()

        Get hash code of this instance. Not suitable to be used as a key as TgaImage is not immutable.

        Overrides:
        hashCode in class Object
        Returns:
        Hash code of this instance.
      • crop

        public void crop(Rectangle rectangle)

        Cropping the image.

        Overrides:
        crop in class RasterCachedImage
        Parameters:
        rectangle - The rectangle.
      • 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.
      • 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.
      • 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.
      • rotate

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

        RasterCachedMultipageImage.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.