public class Layer extends RasterCachedImage implements com.aspose.imaging_internal.ILayer
The psd layer.
Modifier and Type | Field and Description |
---|---|
static int |
BLEND_SIGNATURE
Represents blend mode signature.
|
static int |
LAYER_HEADER_SIZE
The layer header size.
|
Constructor and Description |
---|
Layer()
Initializes a new instance of the
Layer class. |
Layer(RasterImage image)
Initializes a new instance of the
Layer class. |
Layer(Rectangle bounds,
byte[] redBytes,
byte[] greenBytes,
byte[] blueBytes,
String name)
Initializes a new instance of the
Layer class from byte arrays. |
Modifier and Type | Method and Description |
---|---|
void |
addLayerMask(LayerMaskData layerMask)
Adds the mask to current layer.
|
void |
drawImage(Point location,
RasterImage image)
Draws the image on layer.
|
boolean |
equals(Object obj)
Determines whether the specified
System.Object , is equal to this instance. |
int |
getBitsPerPixel()
Gets the image bits per pixel count.
|
BlendingOptions |
getBlendingOptions()
Gets the blending options.
|
long |
getBlendModeKey()
Gets or sets the blend mode key.
|
int |
getBlendModeSignature()
Gets the blend mode signature.
|
int |
getBottom()
Gets or sets the bottom layer position.
|
ChannelInformation[] |
getChannelInformation()
Gets or sets the channel information.
|
int |
getChannelsCount()
Gets the layer's channels count.
|
byte |
getClipping()
Gets or sets the layer clipping.
|
String |
getDisplayName()
Gets the display name of the layer.
|
int |
getExtraLength()
Gets the layer extra information length in bytes.
|
byte |
getFiller()
Gets or sets the layer filler.
|
int |
getFillOpacity()
Gets the fill opacity.
|
byte |
getFlags()
Gets or sets the layer flags.
|
int |
getHeight()
Gets the image height.
|
LayerBlendingRangesData |
getLayerBlendingRangesData()
Gets or sets the layer blending ranges data.
|
Rectangle |
getLayerBounds()
Gets bounds of the layer which can be different from bounds of image container in general case.
|
Date |
getLayerCreationDateTime()
Gets the layer creation date time.
|
int |
getLayerLock()
Gets or sets the layer lock (Note that if flag LayerFlags.TransparencyProtected is set it will be overwritten by layer lock flag.
|
LayerMaskData |
getLayerMaskData()
Gets or sets the layer mask data.
|
PsdOptions |
getLayerOptions()
Gets the layer options.
|
int |
getLeft()
Gets or sets the left layer position.
|
int |
getLength()
Gets the overall layer length in bytes.
|
String |
getName()
Gets or sets the layer name.
|
byte |
getOpacity()
Gets or sets the layer opacity.
|
LayerResource[] |
getResources()
Gets or sets the layer resources.
|
int |
getRight()
Gets or sets the right layer position.
|
short |
getSheetColorHighlight()
Gets the decorative sheet color highlight in layers' list
|
int |
getTop()
Gets or sets the top layer position.
|
int |
getWidth()
Gets the image width.
|
boolean |
hasAlpha()
Gets a value indicating whether this instance has alpha.
|
int |
hashCode()
Returns a hash code for this instance.
|
boolean |
isVisible()
Gets or sets a value indicating whether the layer is visible
|
boolean |
isVisibleInGroup()
Gets a value indicating whether this instance is visible in group(If layer is not in group it means root group).
|
void |
mergeLayerTo(Layer layerToMergeInto)
Merges the layer to specified layer
|
void |
save(com.aspose.ms.System.IO.Stream stream,
ImageOptionsBase optionsBase,
Rectangle boundsRectangle)
Saves the image's data to the specified stream in the specified file format according to save options.
|
void |
save(String filePath,
boolean overWrite)
Saves the object's data to the specified file location.
|
void |
save(String filePath,
ImageOptionsBase options)
Saves the object's data to the specified file location in the specified file format according to save options.
|
void |
save(String filePath,
ImageOptionsBase options,
Rectangle boundsRectangle)
Saves the object's data to the specified file location in the specified file format according to save options.
|
void |
setBlendModeKey(long value)
Gets or sets the blend mode key.
|
void |
setBottom(int value)
Gets or sets the bottom layer position.
|
void |
setChannelInformation(ChannelInformation[] value)
Gets or sets the channel information.
|
void |
setClipping(byte value)
Gets or sets the layer clipping.
|
void |
setFiller(byte value)
Gets or sets the layer filler.
|
void |
setFillOpacity(int value)
The fill opacity.
|
void |
setFlags(byte value)
Gets or sets the layer flags.
|
void |
setLayerBlendingRangesData(LayerBlendingRangesData value)
Gets or sets the layer blending ranges data.
|
void |
setLayerCreationDateTime(Date value)
Sets the layer creation date time.
|
void |
setLayerLock(int value)
Gets or sets the layer lock (Note that if flag LayerFlags.TransparencyProtected is set it will be overwritten by layer lock flag.
|
void |
setLayerMaskData(LayerMaskData value)
Gets or sets the layer mask data.
|
void |
setLeft(int value)
Gets or sets the left layer position.
|
void |
setName(String value)
Gets or sets the layer name.
|
void |
setOpacity(byte value)
Gets or sets the layer opacity.
|
void |
setResources(LayerResource[] value)
Gets or sets the layer resources.
|
void |
setRight(int value)
Gets or sets the right layer position.
|
void |
setSheetColorHighlight(short value)
Sets the decorative sheet color highlight in layers' list
|
void |
setTop(int value)
Gets or sets the top layer position.
|
void |
setVisible(boolean value)
Gets or sets a value indicating whether the layer is visible
|
Layer |
shallowCopy()
Creates a shallow copy of the current Layer.
|
adjustBrightness, adjustContrast, adjustGamma, adjustGamma, binarizeBradley, binarizeBradley, binarizeFixed, binarizeOtsu, cacheData, crop, dither, grayscale, isCached, resize, resize, rotate, rotateFlip
crop, dither, filter, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getHorizontalResolution, getImageOpacity, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataFormat, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, getVerticalResolution, getXmpData, hasTransparentColor, isRawDataAvailable, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceColor, replaceNonTransparentColors, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setHorizontalResolution, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, setVerticalResolution, setXmpData, toBitmap, writeArgb32ScanLine, writeScanLine
canLoad, canLoad, canLoad, canLoad, canSave, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette
getDataStreamContainer, save, save, save
close, dispose, getDisposed
getClass, notify, notifyAll, toString, wait, wait, wait
loadPartialArgb32Pixels
getRawDataSettings, isRawDataAvailable, loadRawData
public static final int LAYER_HEADER_SIZE
The layer header size.
public static final int BLEND_SIGNATURE
Represents blend mode signature.
public Layer()
Initializes a new instance of the Layer
class. Constructor for lazy initialization.
public Layer(RasterImage image)
Initializes a new instance of the Layer
class.
image
- The image.public Layer(Rectangle bounds, byte[] redBytes, byte[] greenBytes, byte[] blueBytes, String name)
Initializes a new instance of the Layer
class from byte arrays.
bounds
- The layer bounds.redBytes
- The red bytes.greenBytes
- The green bytes.blueBytes
- The blue bytes.name
- The layer name.PsdImageException
- Byte arrays can not be empty
or
Byte arrays length must equal bounds dimentions (bounds.Width * bounds.Height)public Layer shallowCopy()
Creates a shallow copy of the current Layer. Please see https://msdn.microsoft.com/ru-ru/library/system.object.memberwiseclone(v=vs.110).aspx for explanation.
public LayerResource[] getResources()
Gets or sets the layer resources.
Value: The layer resources.public void setResources(LayerResource[] value)
Gets or sets the layer resources.
Value: The layer resources.public String getName()
Gets or sets the layer name.
Value: The layer name.public void setName(String value)
Gets or sets the layer name.
Value: The layer name.public final BlendingOptions getBlendingOptions()
Gets the blending options.
Value: The blending options.public String getDisplayName()
Gets the display name of the layer.
Value: The display name of the layer.public final int getFillOpacity()
Gets the fill opacity.
PsdImageArgumentException
- Fill opacity can be only in the range from 0 to 100
Value:
The fill opacity in range from 0 to 100public final void setFillOpacity(int value)
The fill opacity.
value
- the fill opacity.PsdImageArgumentException
- Fill opacity can be only in the range from 0 to 100
Value:
The fill opacity in range from 0 to 100public final Date getLayerCreationDateTime()
Gets the layer creation date time.
Value: The layer's creation date time. If there is no data about creation DateTime then returns Unix Time first epochpublic final void setLayerCreationDateTime(Date value)
Sets the layer creation date time.
Value: The layer's creation date time. If there is no data about creation DateTime then returns Unix Time first epochvalue
- the layer creation date time.public final short getSheetColorHighlight()
Gets the decorative sheet color highlight in layers' list
Value: The sheet color highlight.public final void setSheetColorHighlight(short value)
Sets the decorative sheet color highlight in layers' list
Value: The sheet color highlight.value
- the decorative sheet color highlight in layers' listpublic int getTop()
Gets or sets the top layer position.
Value: The top layer position.public void setTop(int value)
Gets or sets the top layer position.
Value: The top layer position.public int getLeft()
Gets or sets the left layer position.
Value: The left layer position.public void setLeft(int value)
Gets or sets the left layer position.
Value: The left layer position.public int getBottom()
Gets or sets the bottom layer position.
Value: The bottom layer position.public void setBottom(int value)
Gets or sets the bottom layer position.
Value: The bottom layer position.public int getRight()
Gets or sets the right layer position.
Value: The right layer position.public void setRight(int value)
Gets or sets the right layer position.
Value: The right layer position.public int getChannelsCount()
Gets the layer's channels count.
Value: The layer's channels count.public ChannelInformation[] getChannelInformation()
Gets or sets the channel information.
Value: The channel information.public void setChannelInformation(ChannelInformation[] value)
Gets or sets the channel information.
Value: The channel information.public int getBlendModeSignature()
Gets the blend mode signature.
public long getBlendModeKey()
Gets or sets the blend mode key.
Value: The blend mode key.public void setBlendModeKey(long value)
Gets or sets the blend mode key.
Value: The blend mode key.public byte getOpacity()
Gets or sets the layer opacity. 0 = transparent, 255 = opaque.
Value: The layer opacity.public void setOpacity(byte value)
Gets or sets the layer opacity. 0 = transparent, 255 = opaque.
Value: The layer opacity.public byte getClipping()
Gets or sets the layer clipping. 0 = base, 1 = non-base.
Value: The layer clipping.public void setClipping(byte value)
Gets or sets the layer clipping. 0 = base, 1 = non-base.
Value: The layer clipping.public byte getFlags()
Gets or sets the layer flags. bit 0 = transparency protected; bit 1 = visible; bit 2 = obsolete; bit 3 = 1 for Photoshop 5.0 and later, tells if bit 4 has useful information; bit 4 = pixel data irrelevant to appearance of document.
Value: The layer flags.public void setFlags(byte value)
Gets or sets the layer flags. bit 0 = transparency protected; bit 1 = visible; bit 2 = obsolete; bit 3 = 1 for Photoshop 5.0 and later, tells if bit 4 has useful information; bit 4 = pixel data irrelevant to appearance of document.
Value: The layer flags.public byte getFiller()
Gets or sets the layer filler.
Value: The layer filler.public void setFiller(byte value)
Gets or sets the layer filler.
Value: The layer filler.public int getLength()
Gets the overall layer length in bytes.
public int getExtraLength()
Gets the layer extra information length in bytes.
public LayerMaskData getLayerMaskData()
Gets or sets the layer mask data.
Value: The layer mask data.public void setLayerMaskData(LayerMaskData value)
Gets or sets the layer mask data.
Value: The layer mask data.public LayerBlendingRangesData getLayerBlendingRangesData()
Gets or sets the layer blending ranges data.
Value: The layer blending ranges data.public void setLayerBlendingRangesData(LayerBlendingRangesData value)
Gets or sets the layer blending ranges data.
Value: The layer blending ranges data.public int getBitsPerPixel()
Gets the image bits per pixel count.
Value: The image bits per pixel count.getBitsPerPixel
in class Image
public int getHeight()
Gets the image height.
Value: The image height.getHeight
in interface IObjectWithBounds
getHeight
in class Image
public int getWidth()
Gets the image width.
Value: The image width.getWidth
in interface IObjectWithBounds
getWidth
in class Image
public PsdOptions getLayerOptions()
Gets the layer options.
public boolean isVisible()
Gets or sets a value indicating whether the layer is visible
Value:true
if this instance is visible; otherwise, false
.public void setVisible(boolean value)
Gets or sets a value indicating whether the layer is visible
Value:true
if this instance is visible; otherwise, false
.public boolean isVisibleInGroup()
Gets a value indicating whether this instance is visible in group(If layer is not in group it means root group).
Value:true
if this instance is visible in group; otherwise, false
.public int getLayerLock()
Gets or sets the layer lock (Note that if flag LayerFlags.TransparencyProtected is set it will be overwritten by layer lock flag. To return LayerFlags.TransparencyProtected flag need to apply for layer option layer.Flags |= LayerFlags.TransparencyProtected
public void setLayerLock(int value)
Gets or sets the layer lock (Note that if flag LayerFlags.TransparencyProtected is set it will be overwritten by layer lock flag. To return LayerFlags.TransparencyProtected flag need to apply for layer option layer.Flags |= LayerFlags.TransparencyProtected
value
- The layer lock.public boolean hasAlpha()
Gets a value indicating whether this instance has alpha.
hasAlpha
in class RasterImage
true
if this instance has alpha; otherwise, false
.public void save(String filePath, ImageOptionsBase options)
Saves the object's data to the specified file location in the specified file format according to save options.
save
in class Image
filePath
- The file path.options
- The options.The following example loads a PSD image from a file, then saves the PSD image to a PNG file.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Save each layer in a separate PNG file with the default options. int i = 0; com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions(); for (com.aspose.imaging.fileformats.psd.layers.Layer layer : psdImage.getLayers()) { // Some types of layers cannot be exported to raster format. if (layer instanceof com.aspose.imaging.fileformats.psd.layers.LayerGroup || layer instanceof com.aspose.imaging.fileformats.psd.layers.adjustmentlayers.AdjustmentLayer) { continue; } layer.save(dir + "output." + (++i) + ".png", saveOptions); } } finally { image.dispose(); }
public void save(String filePath, boolean overWrite)
Saves the object's data to the specified file location.
save
in class DataStreamSupporter
filePath
- The file path to save the object's data to.overWrite
- if set to true
over write the file contents, otherwise append will occur.public void save(com.aspose.ms.System.IO.Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Saves the image's data to the specified stream in the specified file format according to save options.
stream
- The stream to save the image's data to.optionsBase
- The save options.boundsRectangle
- The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.public void save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Saves the object's data to the specified file location in the specified file format according to save options.
save
in class Image
filePath
- The file path.options
- The options.boundsRectangle
- The destination image bounds rectangle. Set the empty rectangle for use sourse bounds.The following example loads a PSD image from a file, then saves a rectangular part of the PSD image to a PNG file.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Save the upper-left quarter of each layer in a separate PNG file with the default options. int i = 0; com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions(); for (com.aspose.imaging.fileformats.psd.layers.Layer layer : psdImage.getLayers()) { // Some types of layers cannot be exported to raster format. if (layer instanceof com.aspose.imaging.fileformats.psd.layers.LayerGroup || layer instanceof com.aspose.imaging.fileformats.psd.layers.adjustmentlayers.AdjustmentLayer) { continue; } com.aspose.imaging.Rectangle bounds = new com.aspose.imaging.Rectangle(0, 0, layer.getWidth() / 2, layer.getHeight() / 2); layer.save(dir + "output." + (++i) + ".png", saveOptions, bounds); } } finally { image.dispose(); }
public boolean equals(Object obj)
Determines whether the specified System.Object
, is equal to this instance.
public int hashCode()
Returns a hash code for this instance.
public void addLayerMask(LayerMaskData layerMask)
Adds the mask to current layer.
layerMask
- The layer mask.PsdImageException
- Full layer mask is not supported for setting yet, please use LayerMaskDataShortpublic void mergeLayerTo(Layer layerToMergeInto)
Merges the layer to specified layer
layerToMergeInto
- The layer to merge into.public void drawImage(Point location, RasterImage image)
Draws the image on layer.
location
- The location.image
- The image.PsdImageException
- Location must be non-negativepublic Rectangle getLayerBounds()
Gets bounds of the layer which can be different from bounds of image container in general case.
getLayerBounds
in interface com.aspose.imaging_internal.ILayer