public final class ColorModes
extends com.aspose.ms.System.Enum
Represents the psd file format color modes.
An example of converting a 16-bit grayscale PSD to a 16-bit RGB one and then back to 16-bit grayscale but a raster image.
String sourceFilePath = "grayscale5x5.psd"; String exportFilePath = "rgb16bit5x5_output.psd"; String pngExportPath = "rgb16bit5x5_output.png"; // Load a predefined 16-bit grayscale PSD PsdImage image = (PsdImage)Image.load(sourceFilePath); try { RasterCachedImage raster = image.getLayers()[0]; // Draw a gray inner border around the perimeter of the layer Graphics graphics = new Graphics(raster); int width = raster.getWidth(); int height = raster.getHeight(); Rectangle rect = new Rectangle(width / 3, height / 3, width - (2 * (width / 3)) - 1, height - (2 * (height / 3)) - 1); graphics.drawRectangle(new Pen(Color.getDarkGray(), 1), rect); // Save a copy of PSD with the color mode changed to RBG PsdOptions psdOptions = new PsdOptions(); psdOptions.setColorMode(ColorModes.Rgb); psdOptions.setChannelBitsCount((short)16); psdOptions.setChannelsCount((short)4); image.save(exportFilePath, psdOptions); } finally { image.dispose(); } // Load the saved PSD PsdImage image1 = (PsdImage)Image.load(exportFilePath); try { PngOptions pngOptions = new PngOptions(); pngOptions.setColorType(PngColorType.GrayscaleWithAlpha); // Convert the saved PSD to a grayscale PNG image image1.save(pngExportPath, pngOptions); // here should be no exception } finally { image1.dispose(); }
Modifier and Type | Field and Description |
---|---|
static short |
Bitmap
The bitmap color mode.
|
static short |
Cmyk
CMYK color mode.
|
static short |
Duotone
Duotone color mode.
|
static short |
Grayscale
The grayscale mode.
|
static short |
Indexed
Indexed color mode.
|
static short |
Lab
Lab color mode.
|
static short |
Multichannel
Multichannel color mode.
|
static short |
Rgb
RGB color mode.
|
public static final short Bitmap
The bitmap color mode.
public static final short Grayscale
The grayscale mode.
public static final short Indexed
Indexed color mode.
public static final short Rgb
RGB color mode.
public static final short Cmyk
CMYK color mode.
public static final short Multichannel
Multichannel color mode.
public static final short Duotone
Duotone color mode.
public static final short Lab
Lab color mode.