Packages

 

com.aspose.psd.fileformats.psd.resources

Class BackgroundColorResource



  • public final class BackgroundColorResource
    extends ResourceBlock

    The resource with border information of image print settings.

    Code example:

    An example of reading and modifying a background color resource.


                
    String inPsdFilePath = "input.psd";
    String outPsdFilePath = "output.psd";
                
    // Load a PSD file containing a predefined background color resource
    PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath);
    try
    {
        BackgroundColorResource backgroundColorResource = null;
        for (ResourceBlock imageResource : psdImage.getImageResources())
        {
            if (imageResource instanceof BackgroundColorResource)
            {
                backgroundColorResource = (BackgroundColorResource)imageResource;
                break;
            }
        }
                
        if (backgroundColorResource == null)
        {
            throw new Exception("BackgroundColorResource not found");
        }
                
        // Update color of the background color resource
        backgroundColorResource.setColor(Color.getDarkRed());
                
        // Save a modified copy of loaded PSD file on the path
        psdImage.save(outPsdFilePath);
    }
    finally
    {
        psdImage.dispose();
    }
    

    • Constructor Detail

      • BackgroundColorResource

        public BackgroundColorResource()

        Initializes a new instance of the BackgroundColorResource class.

    • Method Detail

      • getDataSize

        public int getDataSize()

        Gets the resource data size in bytes.

        Value: The resource data size.
        Specified by:
        getDataSize in class ResourceBlock
      • getColor

        public final Color getColor()

        Gets or sets the background color.

      • setColor

        public final void setColor(Color value)

        Gets or sets the background color.

      • getMinimalVersion

        public int getMinimalVersion()

        Gets the minimal required PSD version.

        Value: The minimal PSD version.
        Specified by:
        getMinimalVersion in class ResourceBlock
      • setColorSpace

        public final void setColorSpace(int value)

        Gets or sets a color space.

        Value: The background color space.