public final class PsdImage extends RasterCachedImage
Defines the PsdImage class that provides the ability to load, edit, save PSD files as well as update properties, add watermarks, perform graphics operations or convert one file format to another. Aspose.PSD supports import as a layer and export to the following formats: Png, Jpeg, Jpeg2000, Gif, Bmp, Tiff, Psd, Psb along with export to Pdf with selectable text
An example of support of layer masks for layer groups. The program loads and saves PSD to different output formats without throwing exceptions.
String srcFile = "psdnet595.psd"; String outputPng = "output.png"; String outputPsd = "output.psd"; // Load a predefined PSD containing layer masks for layer groups PsdImage input = (PsdImage)Image.load(srcFile); try { // Convert loaded PSD to PNG input.save(outputPng, new PngOptions()); // Save a copy of the PSD input.save(outputPsd); } finally { input.dispose(); }
RasterCachedImage.RotateTestMode
Modifier and Type | Field and Description |
---|---|
static int |
DefaultVersion
The default PSD version.
|
Constructor and Description |
---|
PsdImage(InputStream stream)
Initializes a new instance of the
PsdImage class from specified path from raster image (not psd image in stream). |
PsdImage(InputStream stream,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Initializes a new instance of the
PsdImage class from specified path from raster image (not psd image in stream) with constructor parameters. |
PsdImage(int width,
int height)
Initializes a new instance of the
PsdImage class with specified width and height. |
PsdImage(int width,
int height,
IColorPalette colorPalette,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Initializes a new instance of the
PsdImage class with specified width,height, paletter, color mode, channels count and channels bit-length and specified compression mode parameters. |
PsdImage(RasterImage rasterImage)
Initializes a new instance of the
PsdImage class from existing raster image (not psd image) with RGB color mode with 4 channels 8 bit/channel and no compression. |
PsdImage(RasterImage rasterImage,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Initializes a new instance of the
PsdImage class from existing raster image (not psd image) with constructor parameters. |
PsdImage(String path)
Initializes a new instance of the
PsdImage class from specified path from raster image (not psd image in path). |
PsdImage(String path,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Initializes a new instance of the
PsdImage class from specified path from raster image (not psd image in path) with constructor parameters. |
Modifier and Type | Method and Description |
---|---|
BlackWhiteAdjustmentLayer |
addBlackWhiteAdjustmentLayer()
Adds the black white adjustment layer.
|
BrightnessContrastLayer |
addBrightnessContrastAdjustmentLayer(int brightness,
int contrast)
Adds the brightness/contrast adjustment layer.
|
ChannelMixerLayer |
addChannelMixerAdjustmentLayer()
Adds the channel mixer adjustment layer with default parameters
|
ColorBalanceAdjustmentLayer |
addColorBalanceAdjustmentLayer()
Adds the color balance adjustment layer.
|
CurvesLayer |
addCurvesAdjustmentLayer()
Adds the Curves Adjustment layer.
|
ExposureLayer |
addExposureAdjustmentLayer() |
ExposureLayer |
addExposureAdjustmentLayer(float exposure) |
ExposureLayer |
addExposureAdjustmentLayer(float exposure,
float offset) |
ExposureLayer |
addExposureAdjustmentLayer(float exposure,
float offset,
float gammaCorrection)
Adds the exposure adjustment layer.
|
HueSaturationLayer |
addHueSaturationAdjustmentLayer()
Adds the hue/saturation adjustment layer.
|
InvertAdjustmentLayer |
addInvertAdjustmentLayer()
Adds an invert adjustment layer.
|
void |
addLayer(Layer layer)
Adds the layer.
|
LayerGroup |
addLayerGroup(String groupName,
int index,
boolean startBehaviour)
Adds the layer group.
|
LevelsLayer |
addLevelsAdjustmentLayer()
Adds the Levels adjustment layer.
|
PhotoFilterLayer |
addPhotoFilterLayer(Color color)
Adds the photofilter layer.
|
Layer |
addRegularLayer()
Adds a new regular layer.
|
TextLayer |
addTextLayer(String text,
Rectangle rect)
Adds a new Text layer.
|
void |
adjustBrightness(int brightness)
Adjust of a brightness for image.
|
void |
adjustContrast(float contrast)
Image contrasting
|
void |
adjustGamma(float gamma)
Gamma-correction of an image.
|
void |
adjustGamma(float gammaRed,
float gammaGreen,
float gammaBlue)
Gamma-correction of an image.
|
void |
binarizeBradley(double brightnessDifference)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
|
void |
binarizeBradley(double brightnessDifference,
int windowSize)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
|
void |
binarizeFixed(byte threshold)
Binarization of an image with predefined threshold
|
void |
binarizeOtsu()
Binarization of an image with Otsu thresholding
|
void |
convert(PsdOptions newOptions)
Converts this image format to the one specified in options.
|
void |
crop(Rectangle rectangle)
Cropping the image.
|
void |
dither(int ditheringMethod,
int bitsCount,
IColorPalette customPalette)
Performs dithering on the current image.
|
void |
filter(Rectangle rectangle,
FilterOptionsBase options)
Filters the specified rectangle.
|
void |
flattenImage()
Flattens all layers.
|
Layer |
getActiveLayer()
Gets or sets the active layer.
|
int |
getBitsPerChannel()
Gets the bits per channel.
|
int |
getBitsPerPixel()
Gets the image bits per pixel count.
|
int |
getChannelsCount()
Gets the PSD channels count.
|
StreamSource |
getCmykColorProfile()
Gets or sets the CMYK color profile for CMYK PSD images.
|
short |
getColorMode()
Gets or sets the color mode.
|
short |
getCompression()
Gets the compression method.
|
long |
getFileFormat()
Gets a value of file format
|
int |
getGlobalAngle()
Gets or sets the global angle.
|
GlobalLayerMaskInfo |
getGlobalLayerMaskInfo()
Gets the global layer mask info.
|
LayerResource[] |
getGlobalLayerResources()
Gets or sets the global layer resources.
|
StreamSource |
getGrayColorProfile()
Gets or sets the GRAY (monochrome) color profile for Grayscale PSD images.
|
int |
getHeight()
Gets the image height.
|
double |
getHorizontalResolution()
Gets or sets the horizontal resolution, in pixels per inch, of this
PsdImage . |
ResourceBlock[] |
getImageResources()
Gets or sets the PSD image resources.
|
Layer[] |
getLayers()
Gets or sets the PSD layers.
|
LinkedLayersManager |
getLinkedLayersManager()
Gets the linked layers manager.
|
PixelDataFormat |
getRawDataFormat()
Gets the raw data format.
|
StreamSource |
getRgbColorProfile()
Gets or sets the RGB color profile for CMYK PSD images.
|
SmartObjectProvider |
getSmartObjectProvider()
Gets the smart object provider.
|
int |
getVersion()
Gets or sets the version.
|
double |
getVerticalResolution()
Gets or sets the vertical resolution, in pixels per inch, of this
PsdImage . |
int |
getWidth()
Gets the image width.
|
XmpPacketWrapper |
getXmpData()
Gets or sets the XMP metadata.
|
void |
grayscale()
Transformation of an image to its grayscale representation
|
boolean |
hasAlpha()
Gets or sets the vertical resolution, in pixels per inch, of this
RasterImage . |
boolean |
hasTransparencyData()
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
|
boolean |
isFlatten()
Gets a value indicating whether psd image is flattened.
|
Layer |
mergeLayers(Layer bottomLayer,
Layer topLayer)
Merges the layers.
|
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.
|
void |
replaceNonTransparentColors(int newColorArgb)
Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges.
|
void |
resizeHeightProportionally(int newHeight,
ImageResizeSettings settings)
Resizes the height proportionally.
|
void |
resizeHeightProportionally(int newHeight,
int resizeType)
Resizes the height proportionally.
|
void |
resizeWidthProportionally(int newWidth,
ImageResizeSettings settings)
Resizes the width proportionally.
|
void |
resizeWidthProportionally(int newWidth,
int resizeType)
Resizes the width proportionally.
|
void |
rotate(float angle)
Rotate image around the center.
|
void |
rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
Rotate image around the center.
|
void |
setActiveLayer(Layer value)
Gets or sets the active layer.
|
void |
setCmykColorProfile(StreamSource value)
Gets or sets the CMYK color profile for CMYK PSD images.
|
void |
setColorMode(short value)
Gets or sets the color mode.
|
void |
setGlobalAngle(int value)
The global angle.
|
void |
setGlobalLayerResources(LayerResource[] value)
Gets or sets the global layer resources.
|
void |
setGrayColorProfile(StreamSource value)
The GRAY (monochrome) color profile for Grayscale PSD images.
|
void |
setHorizontalResolution(double value)
Gets or sets the horizontal resolution, in pixels per inch, of this
PsdImage . |
void |
setImageResources(ResourceBlock[] value)
Gets or sets the PSD image resources.
|
void |
setLayers(Layer[] value)
Gets or sets the PSD layers.
|
void |
setRgbColorProfile(StreamSource value)
Gets or sets the RGB color profile for CMYK PSD images.
|
void |
setTransparencyData(boolean value)
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
|
void |
setVersion(int value)
Gets or sets the version.
|
void |
setVerticalResolution(double value)
Gets or sets the vertical resolution, in pixels per inch, of this
PsdImage . |
void |
setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata.
|
cacheData, doRotate, getRotateMode, isCached, resize, resize, rotateFlip
crop, dither, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getImageOpacity, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, hasTransparentColor, isRawDataAvailable, isUsePalette, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceNonTransparentColors, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, toBitmap, writeArgb32ScanLine, writeScanLine
canLoad, canLoad, canLoad, canLoad, canSave, create, create, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette
getDataStreamContainer, save, save, save, save, setDataStreamContainer
close, dispose, getDisposed
public static final int DefaultVersion
The default PSD version.
public PsdImage(String path)
Initializes a new instance of the PsdImage
class from specified path from raster image (not psd image in path). Used to initialize psd image with default parameters - Color mode - rgb, 4 channels, 8 bit per channel, Compression - Raw.
path
- The path to load pixel and palette data from and initialize with.public PsdImage(String path, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Initializes a new instance of the PsdImage
class from specified path from raster image (not psd image in path) with constructor parameters.
path
- The path to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.public PsdImage(InputStream stream)
Initializes a new instance of the PsdImage
class from specified path from raster image (not psd image in stream). Used to initialize psd image with default parameters - Color mode - rgb, 4 channels, 8 bit per channel, Compression - Raw.
stream
- The stream to load pixel and palette data from and initialize with.public PsdImage(InputStream stream, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Initializes a new instance of the PsdImage
class from specified path from raster image (not psd image in stream) with constructor parameters.
stream
- The stream to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.public PsdImage(RasterImage rasterImage)
Initializes a new instance of the PsdImage
class from existing raster image (not psd image) with RGB color mode with 4 channels 8 bit/channel and no compression.
rasterImage
- The image to load pixel and palette data from and initialize with.public PsdImage(RasterImage rasterImage, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Initializes a new instance of the PsdImage
class from existing raster image (not psd image) with constructor parameters.
rasterImage
- The image to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.public PsdImage(int width, int height)
Initializes a new instance of the PsdImage
class with specified width and height. Used to initialize empty psd image.
width
- The image width.height
- The image height.public PsdImage(int width, int height, IColorPalette colorPalette, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Initializes a new instance of the PsdImage
class with specified width,height, paletter, color mode, channels count and channels bit-length and specified compression mode parameters. Used to initialize empty psd image.
width
- The image width.height
- The image height.colorPalette
- The color palette.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.public XmpPacketWrapper getXmpData()
Gets or sets the XMP metadata.
Value: The XMP metadata.getXmpData
in class RasterImage
public void setXmpData(XmpPacketWrapper value)
Gets or sets the XMP metadata.
Value: The XMP metadata.setXmpData
in class RasterImage
value
- The XMP metadata.public long getFileFormat()
Gets a value of file format
getFileFormat
in class Image
public boolean hasAlpha()
Gets or sets the vertical resolution, in pixels per inch, of this RasterImage
.
true
if this instance has alpha; otherwise, false
.hasAlpha
in class RasterImage
true
if this instance has alpha; otherwise, false
.public double getVerticalResolution()
Gets or sets the vertical resolution, in pixels per inch, of this PsdImage
.
getVerticalResolution
in class RasterImage
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.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Value:
The vertical resolution.
ResolutionInfoResource
wasn't found, this value is returned.
public void setVerticalResolution(double value)
Gets or sets the vertical resolution, in pixels per inch, of this PsdImage
.
setVerticalResolution
in class RasterImage
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.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Value:
The vertical resolution.
ResolutionInfoResource
wasn't found, this value is returned.
public double getHorizontalResolution()
Gets or sets the horizontal resolution, in pixels per inch, of this PsdImage
.
getHorizontalResolution
in class RasterImage
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.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Value:
The horizontal resolution.
ResolutionInfoResource
wasn't found, this value is returned.
public void setHorizontalResolution(double value)
Gets or sets the horizontal resolution, in pixels per inch, of this PsdImage
.
setHorizontalResolution
in class RasterImage
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.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Value:
The horizontal resolution.
ResolutionInfoResource
wasn't found, this value is returned.
public final StreamSource getRgbColorProfile()
Gets or sets the RGB color profile for CMYK PSD images. Must be in pair with CmykColorProfile for correct color conversion.
Value: The RGB color profile.public final void setRgbColorProfile(StreamSource value)
Gets or sets the RGB color profile for CMYK PSD images. Must be in pair with CmykColorProfile for correct color conversion.
Value: The RGB color profile.public final StreamSource getCmykColorProfile()
Gets or sets the CMYK color profile for CMYK PSD images. Must be in pair with RgbColorProfile for correct color conversion.
Value: The CMYK color profile.public final void setCmykColorProfile(StreamSource value)
Gets or sets the CMYK color profile for CMYK PSD images. Must be in pair with RgbColorProfile for correct color conversion.
Value: The CMYK color profile.public final StreamSource getGrayColorProfile()
Gets or sets the GRAY (monochrome) color profile for Grayscale PSD images.
Value: The GRAY (monochrome) color profile.public final void setGrayColorProfile(StreamSource value)
The GRAY (monochrome) color profile for Grayscale PSD images.
Value: The GRAY (monochrome) color profile.public final short getColorMode()
Gets or sets the color mode.
Value: The color mode.public final void setColorMode(short value)
Gets or sets the color mode.
Value: The color mode.public final short getCompression()
Gets the compression method.
Value: The compression.public final int getChannelsCount()
Gets the PSD channels count.
Value: The PSD channels count.public final int getBitsPerChannel()
Gets the bits per channel.
Value: The bits per channel.public final ResourceBlock[] getImageResources()
Gets or sets the PSD image resources.
Value: The PSD image resources.public final void setImageResources(ResourceBlock[] value)
Gets or sets the PSD image resources.
Value: The PSD image resources.public final int getVersion()
Gets or sets the version.
Value: The version.public final void setVersion(int value)
Gets or sets the version.
Value: The version.public int getWidth()
Gets the image width.
Value: The image width.getWidth
in interface IObjectWithBounds
getWidth
in class Image
public int getHeight()
Gets the image height.
Value: The image height.getHeight
in interface IObjectWithBounds
getHeight
in class Image
public int getBitsPerPixel()
Gets the image bits per pixel count.
Value: The image bits per pixel count.getBitsPerPixel
in class Image
public final Layer[] getLayers()
Gets or sets the PSD layers.
Value: The PSD layers.public final void setLayers(Layer[] value)
Gets or sets the PSD layers.
Value: The PSD layers.public final LayerResource[] getGlobalLayerResources()
Gets or sets the global layer resources.
Value: The global layer resources.public final void setGlobalLayerResources(LayerResource[] value)
Gets or sets the global layer resources.
Value: The global layer resources.public final GlobalLayerMaskInfo getGlobalLayerMaskInfo()
Gets the global layer mask info.
public final boolean hasTransparencyData()
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
Value:true
if first alpha channel contains the transparency data for the merged result when specifying layers data; otherwise, false
.public final void setTransparencyData(boolean value)
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
Value:true
if first alpha channel contains the transparency data for the merged result when specifying layers data; otherwise, false
.public final Layer getActiveLayer()
Gets or sets the active layer.
TiffImageException
- There is no active layer and no layers in image.PsdImageException
- The active layer cannot be set as it belongs to another image.
Value:
The active layer.public final void setActiveLayer(Layer value)
Gets or sets the active layer.
TiffImageException
- There is no active layer and no layers in image.PsdImageException
- The active layer cannot be set as it belongs to another image.
Value:
The active layer.public final boolean isFlatten()
Gets a value indicating whether psd image is flattened.
Value:true
if this instance is flatten; otherwise, false
.public PixelDataFormat getRawDataFormat()
Gets the raw data format.
Value: The raw data format.getRawDataFormat
in class RasterImage
public final int getGlobalAngle()
Gets or sets the global angle.
public final void setGlobalAngle(int value)
The global angle.
public final LinkedLayersManager getLinkedLayersManager()
Gets the linked layers manager.
public final SmartObjectProvider getSmartObjectProvider()
Gets the smart object provider.
Value: The smart object provider.public final void addLayer(Layer layer)
Adds the layer.
layer
- The layer.An example of drawing on a layer created by no-argument constructor. It adds a manually initialized layer to the document and draws a couple of simple figures on it then saves a changed copy of the document as a new PSD file.
String outPsdFilePath = "output.psd"; int width = 100; int height = 100; // Create a new document of the appropriate size PsdImage image = new PsdImage(width, height); try { // Add a layer created by no-argument constructor to the document Layer layer = new Layer(); layer.setBottom(height); layer.setRight(width); image.addLayer(layer); Graphics graphic = new Graphics(layer); // Clear the canvas and paint it up with a yellow color graphic.clear(Color.getYellow()); // Draw a rectangle using the Pen tool graphic.drawRectangle(new Pen(Color.getRed()), new Rectangle(30, 10, 40, 80)); // Draw another rectangle using Solid Brush with a Blue color graphic.drawRectangle(new Pen(new SolidBrush(Color.getBlue())), new Rectangle(10, 30, 80, 40)); // Save a copy of the loaded PSD file including the changes on the specified path image.save(outPsdFilePath); } finally { image.dispose(); }
public final Layer mergeLayers(Layer bottomLayer, Layer topLayer)
Merges the layers.
bottomLayer
- The bottom layer.topLayer
- The top layer.public final void flattenImage()
Flattens all layers.
public final Layer addRegularLayer()
Adds a new regular layer.
public final TextLayer addTextLayer(String text, Rectangle rect)
Adds a new Text layer.
text
- The layer's text.rect
- The layer's rectangle.public final CurvesLayer addCurvesAdjustmentLayer()
Adds the Curves Adjustment layer.
CurvesLayer
Layerpublic final ExposureLayer addExposureAdjustmentLayer()
public final ExposureLayer addExposureAdjustmentLayer(float exposure)
public final ExposureLayer addExposureAdjustmentLayer(float exposure, float offset)
public final ExposureLayer addExposureAdjustmentLayer(float exposure, float offset, float gammaCorrection)
Adds the exposure adjustment layer.
exposure
- The exposure.offset
- The offset.gammaCorrection
- The gamma correction.public final HueSaturationLayer addHueSaturationAdjustmentLayer()
Adds the hue/saturation adjustment layer.
public final ColorBalanceAdjustmentLayer addColorBalanceAdjustmentLayer()
Adds the color balance adjustment layer.
public final LevelsLayer addLevelsAdjustmentLayer()
Adds the Levels adjustment layer.
public final PhotoFilterLayer addPhotoFilterLayer(Color color)
Adds the photofilter layer.
color
- The color.public final ChannelMixerLayer addChannelMixerAdjustmentLayer()
Adds the channel mixer adjustment layer with default parameters
public final BrightnessContrastLayer addBrightnessContrastAdjustmentLayer(int brightness, int contrast)
Adds the brightness/contrast adjustment layer.
brightness
- The brightness.contrast
- The contrast.public final InvertAdjustmentLayer addInvertAdjustmentLayer()
Adds an invert adjustment layer.
public final BlackWhiteAdjustmentLayer addBlackWhiteAdjustmentLayer()
Adds the black white adjustment layer.
public final LayerGroup addLayerGroup(String groupName, int index, boolean startBehaviour)
Adds the layer group.
groupName
- Name of the group.index
- The index of the layer to insert after.startBehaviour
- if set to true
[start behaviour] than group will be in open state on start up, otherwise in minimized state.PsdImageException
- Index must be in bounds of Layers countpublic void rotate(float angle)
Rotate image around the center.
rotate
in class RasterImage
angle
- The rotate angle in degrees. Positive values will rotate clockwise.public void rotate(float angle, boolean resizeProportionally, Color backgroundColor)
Rotate image around the center.
rotate
in class RasterCachedImage
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.public void crop(Rectangle rectangle)
Cropping the image.
crop
in class RasterCachedImage
rectangle
- The rectangle.public final void convert(PsdOptions newOptions)
Converts this image format to the one specified in options.
newOptions
- The new options.public void resizeHeightProportionally(int newHeight, ImageResizeSettings settings)
Resizes the height proportionally.
resizeHeightProportionally
in class Image
newHeight
- The new height.settings
- The image resize settings.public void resizeHeightProportionally(int newHeight, int resizeType)
Resizes the height proportionally.
resizeHeightProportionally
in class Image
newHeight
- The new height.resizeType
- Type of the resize.public void resizeWidthProportionally(int newWidth, ImageResizeSettings settings)
Resizes the width proportionally.
resizeWidthProportionally
in class Image
newWidth
- The new width.settings
- The image resize settings.public void resizeWidthProportionally(int newWidth, int resizeType)
Resizes the width proportionally.
resizeWidthProportionally
in class Image
newWidth
- The new width.resizeType
- Type of the resize.public void dither(int ditheringMethod, int bitsCount, IColorPalette customPalette)
Performs dithering on the current image.
dither
in class RasterCachedImage
ditheringMethod
- The dithering method.bitsCount
- The final bits count for dithering.customPalette
- The custom palette for dithering.public void binarizeOtsu()
Binarization of an image with Otsu thresholding
binarizeOtsu
in class RasterCachedImage
public void binarizeBradley(double brightnessDifference, int windowSize)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
binarizeBradley
in class RasterCachedImage
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 pixelpublic void binarizeBradley(double brightnessDifference)
Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding
binarizeBradley
in class RasterCachedImage
brightnessDifference
- The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.public void adjustBrightness(int brightness)
Adjust of a brightness for image.
adjustBrightness
in class RasterCachedImage
brightness
- Brightness value.public void adjustGamma(float gamma)
Gamma-correction of an image.
adjustGamma
in class RasterCachedImage
gamma
- Gamma for red, green and blue channels coefficientpublic void adjustContrast(float contrast)
Image contrasting
adjustContrast
in class RasterCachedImage
contrast
- Contrast value (in range [-100; 100])public void adjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Gamma-correction of an image.
adjustGamma
in class RasterCachedImage
gammaRed
- Gamma for red channel coefficientgammaGreen
- Gamma for green channel coefficientgammaBlue
- Gamma for blue channel coefficientpublic void binarizeFixed(byte threshold)
Binarization of an image with predefined threshold
binarizeFixed
in class RasterCachedImage
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.public void grayscale()
Transformation of an image to its grayscale representation
grayscale
in class RasterCachedImage
public void filter(Rectangle rectangle, FilterOptionsBase options)
Filters the specified rectangle.
filter
in class RasterImage
rectangle
- The rectangle.options
- The options.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.
replaceColor
in class RasterImage
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.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.
replaceNonTransparentColors
in class RasterImage
newColorArgb
- New color ARGB value to replace non transparent colors with.