Class TextLayer
Contents
[
Hide
]TextLayer class
The text layer class
public class TextLayer : Layer
Properties
Name | Description |
---|---|
AutoAdjustPalette { get; set; } | Gets or sets a value indicating whether automatic adjust palette. |
virtual BackgroundColor { get; set; } | Gets or sets a value for the background color. |
override BitsPerPixel { get; } | Gets the image bits per pixel count. |
BlendClippedElements { get; set; } | Gets or sets the blending of clipped element. |
BlendingOptions { get; } | Gets the blending options. |
virtual BlendModeKey { get; set; } | Gets or sets the blend mode key. |
BlendModeSignature { get; } | Gets the blend mode signature. |
virtual Bottom { get; set; } | Gets or sets the bottom layer position. |
Bounds { get; } | Gets the image bounds. |
BufferSizeHint { get; set; } | Gets or sets the buffer size hint which is defined max allowed size for all internal buffers. |
ChannelInformation { get; set; } | Gets or sets the channel information. |
ChannelsCount { get; } | Gets the layer’s channels count. |
Clipping { get; set; } | Gets or sets the layer clipping. 0 = base, 1 = non-base. |
Container { get; } | Gets the Image container. |
DataStreamContainer { get; } | Gets the object’s data stream. |
DisplayName { get; set; } | Gets or sets the display name of the layer. |
Disposed { get; } | Gets a value indicating whether this instance is disposed. |
ExtraLength { get; } | Gets the layer extra information length in bytes. |
virtual FileFormat { get; } | Gets a value of file format |
Filler { get; set; } | Gets or sets the layer filler. |
FillOpacity { get; set; } | Gets or sets the fill opacity. |
Flags { get; set; } | 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. |
Font { get; } | Gets the font. |
override HasAlpha { get; } | Gets a value indicating whether this instance has alpha. |
virtual HasBackgroundColor { get; set; } | Gets or sets a value indicating whether image has background color. |
virtual HasTransparentColor { get; set; } | Gets a value indicating whether image has transparent color. |
override Height { get; } | Gets the image height. |
virtual HorizontalResolution { get; set; } | Gets or sets the horizontal resolution, in pixels per inch, of this RasterImage . |
virtual ImageOpacity { get; } | Gets opacity of this image. |
InnerText { get; } | Gets the text of the layer |
InterruptMonitor { get; set; } | Gets or sets the interrupt monitor. |
override IsCached { get; } | Gets a value indicating whether image data is cached currently. |
IsRawDataAvailable { get; } | Gets a value indicating whether raw data loading is available. |
IsVisible { get; set; } | Gets or sets a value indicating whether the layer is visible |
virtual IsVisibleInGroup { get; } | Gets a value indicating whether this instance is visible in group(If layer is not in group it means root group). |
LayerBlendingRangesData { get; set; } | Gets or sets the layer blending ranges data. |
LayerCreationDateTime { get; set; } | Gets or sets the layer creation date time. |
LayerLock { get; set; } | 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 |
LayerMaskData { get; set; } | Gets or sets the layer mask data. |
LayerOptions { get; } | Gets the layer options. |
virtual Left { get; set; } | Gets or sets the left layer position. |
Length { get; } | Gets the overall layer length in bytes. |
Name { get; set; } | Gets or sets the layer name. |
Opacity { get; set; } | Gets or sets the layer opacity. 0 = transparent, 255 = opaque. |
Palette { get; set; } | Gets or sets the color palette. The color palette is not used when pixels are represented directly. |
virtual PremultiplyComponents { get; set; } | Gets or sets a value indicating whether the image components must be premultiplied. |
RawCustomColorConverter { get; set; } | Gets or sets the custom color converter |
virtual RawDataFormat { get; } | Gets the raw data format. |
RawDataSettings { get; } | Gets the current raw data settings. Note when using these settings the data loads without conversion. |
RawFallbackIndex { get; set; } | Gets or sets the fallback index to use when palette index is out of bounds |
RawIndexedColorConverter { get; set; } | Gets or sets the indexed color converter |
virtual RawLineSize { get; } | Gets the raw line size in bytes. |
Resources { get; set; } | Gets or sets the layer resources. |
virtual Right { get; set; } | Gets or sets the right layer position. |
SheetColorHighlight { get; set; } | Gets or sets the decorative sheet color highlight in layers’ list |
Size { get; } | Gets the image size. |
Text { get; } | Gets the text. |
TextBoundBox { get; set; } | Gets or sets the text bound box. |
TextColor { get; } | Gets the color of the text. |
TextData { get; } | Gets the texts portions. |
virtual Top { get; set; } | Gets or sets the top layer position. |
TransformMatrix { get; set; } | Gets or sets the transform matrix |
virtual TransparentColor { get; set; } | Gets the image transparent color. |
virtual UpdateXmpData { get; set; } | Gets or sets a value indicating whether to update the XMP metadata. |
virtual UsePalette { get; } | Gets a value indicating whether the image palette is used. |
virtual UseRawData { get; set; } | Gets or sets a value indicating whether to use raw data loading when the raw data loading is available. |
virtual VerticalResolution { get; set; } | Gets or sets the vertical resolution, in pixels per inch, of this RasterImage . |
WarpSettings { get; set; } | It gets or sets Warp parameters that was set or get from resource (default) |
override Width { get; } | Gets the image width. |
virtual XmpData { get; set; } | Gets or sets the XMP metadata. |
Methods
Name | Description |
---|---|
AddLayerMask(LayerMaskData) | Adds the mask to current layer. |
override AdjustBrightness(int) | Adjust of a brightness for image. |
override AdjustContrast(float) | Image contrasting |
override AdjustGamma(float) | Gamma-correction of an image. |
override AdjustGamma(float, float, float) | Gamma-correction of an image. |
override BinarizeBradley(double) | Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding |
override BinarizeBradley(double, int) | Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding |
override BinarizeFixed(byte) | Binarization of an image with predefined threshold |
override BinarizeOtsu() | Binarization of an image with Otsu thresholding |
override CacheData() | Caches the data and ensures no additional data loading will be performed from the underlying DataStreamContainer . |
CanSave(ImageOptionsBase) | Determines whether image can be saved to the specified file format represented by the passed save options. |
override Crop(Rectangle) | Cropping the image. |
virtual Crop(int, int, int, int) | Crop image with shifts. |
Dispose() | Disposes the current instance. |
Dither(DitheringMethod, int) | Performs dithering on the current image. |
override Dither(DitheringMethod, int, IColorPalette) | Performs dithering on the current image. |
DrawImage(Point, RasterImage) | Draws the image on layer. |
virtual Filter(Rectangle, FilterOptionsBase) | Filters the specified rectangle. |
GetArgb32Pixel(int, int) | Gets an image 32-bit ARGB pixel. |
GetDefaultArgb32Pixels(Rectangle) | Gets the default 32-bit ARGB pixels array. |
virtual GetDefaultOptions(object[]) | Gets the default options. |
GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) | Gets the default pixels array using partial pixel loader. |
GetDefaultRawData(Rectangle, RawDataSettings) | Gets the default raw data array. |
GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) | Gets the default raw data array using partial pixel loader. |
GetFonts() | Gets the fonts set of the text layer. |
override GetHashCode() | Returns a hash code for this instance. |
virtual GetModifyDate(bool) | Gets the date and time the resource image was last modified. |
virtual GetOriginalOptions() | Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Save method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Save method as the second parameter. |
GetPixel(int, int) | Gets an image pixel. Performance Warning: Avoid using this method to iterate over all image pixels as it can lead to significant performance issues. For more efficient pixel manipulation, use the LoadArgb32Pixels method to retrieve the entire pixel array simultaneously. |
GetSkewAngle() | Gets the skew angle. This method is applicable to scanned text documents, to determine the skew angle when scanning. |
override Grayscale() | Transformation of an image to its grayscale representation |
LoadArgb32Pixels(Rectangle) | Loads 32-bit ARGB pixels. |
LoadArgb64Pixels(Rectangle) | Loads 64-bit ARGB pixels. |
LoadCmyk32Pixels(Rectangle) | Loads pixels in CMYK format. |
LoadCmykPixels(Rectangle) | Loads pixels in CMYK format. This method is deprecated. Please use more effective the LoadCmyk32Pixels method. |
LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) | Loads 32-bit ARGB pixels partially by packs. |
LoadPartialPixels(Rectangle, IPartialPixelLoader) | Loads pixels partially by packs. |
LoadPixels(Rectangle) | Loads pixels. |
LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) | Loads raw data. |
LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) | Loads raw data. |
virtual MergeLayerTo(Layer) | Merges the layer to specified layer |
NormalizeAngle() | Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses GetSkewAngle and Rotate methods. |
virtual NormalizeAngle(bool, Color) | Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses GetSkewAngle and Rotate methods. |
ReadArgb32ScanLine(int) | Reads the whole scan line by the specified scan line index. |
ReadScanLine(int) | Reads the whole scan line by the specified scan line index. |
ReplaceColor(Color, byte, Color) | Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges. |
virtual ReplaceColor(int, byte, int) | Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges. |
ReplaceNonTransparentColors(Color) | 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. |
virtual ReplaceNonTransparentColors(int) | 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. |
Resize(int, int) | Resizes the image. The default NearestNeighbourResample is used. |
override Resize(int, int, ImageResizeSettings) | Resizes the image. |
override Resize(int, int, ResizeType) | Resizes the image. The default LeftTopToLeftTop is used. |
ResizeHeightProportionally(int) | Resizes the height proportionally. |
virtual ResizeHeightProportionally(int, ImageResizeSettings) | Resizes the height proportionally. |
virtual ResizeHeightProportionally(int, ResizeType) | Resizes the height proportionally. |
ResizeWidthProportionally(int) | Resizes the width proportionally. The default NearestNeighbourResample is used. |
virtual ResizeWidthProportionally(int, ImageResizeSettings) | Resizes the width proportionally. |
virtual ResizeWidthProportionally(int, ResizeType) | Resizes the width proportionally. |
virtual Rotate(float) | Rotate image around the center. |
override Rotate(float, bool, Color) | Rotate image around the center. |
override RotateFlip(RotateFlipType) | Rotates, flips, or rotates and flips the image. |
Save() | Saves the image data to the underlying stream. |
override Save(Stream) | Saves the object’s data to the specified stream. |
Save(string) | Saves the object’s data to the specified file location. |
Save(Stream, ImageOptionsBase) | Saves the image’s data to the specified stream in the specified file format according to save options. |
override Save(string, bool) | Saves the object’s data to the specified file location. |
override Save(string, ImageOptionsBase) | Saves the object’s data to the specified file location in the specified file format according to save options. |
override Save(Stream, ImageOptionsBase, Rectangle) | Saves the image’s data to the specified stream in the specified file format according to save options. |
override Save(string, ImageOptionsBase, Rectangle) | Saves the object’s data to the specified file location in the specified file format according to save options. |
SaveArgb32Pixels(Rectangle, int[]) | Saves the 32-bit ARGB pixels. |
SaveCmyk32Pixels(Rectangle, int[]) | Saves the pixels. |
SaveCmykPixels(Rectangle, CmykColor[]) | Saves the pixels. This method is deprecated. Please use more effective the SaveCmyk32Pixels method. |
SavePixels(Rectangle, Color[]) | Saves the pixels. |
SaveRawData(byte[], int, Rectangle, RawDataSettings) | Saves the raw data. |
SetArgb32Pixel(int, int, int) | Sets an image 32-bit ARGB pixel for the specified position. |
override SetPalette(IColorPalette, bool) | Sets the image palette. |
SetPixel(int, int, Color) | Sets an image pixel for the specified position. |
virtual SetResolution(double, double) | Sets the resolution for this RasterImage . |
ShallowCopy() | Creates a shallow copy of the current Layer. Please https://msdn.microsoft.com/ru-ru/library/system.object.memberwiseclone(v=vs.110).aspx for explanation. |
virtual ToBitmap() | Converts raster image to the bitmap. |
UpdateText(string) | Updates the text. |
UpdateText(string, Color) | Updates the text. |
UpdateText(string, float) | Updates the text. |
UpdateText(string, Point) | Updates the text. |
UpdateText(string, float, Color) | Updates the text. |
UpdateText(string, Point, Color) | Updates the text. |
UpdateText(string, Point, float) | Updates the text. |
UpdateText(string, Point, float, Color) | Updates the text. |
WriteArgb32ScanLine(int, int[]) | Writes the whole scan line to the specified scan line index. |
WriteScanLine(int, Color[]) | Writes the whole scan line to the specified scan line index. |
Examples
The following example demonstrates that the Text Alignment through ITextPortion for right-to-left languages works correctly.
[C#]
string sourceFilePath = "bidi.psd";
string exportFilePath = "bidiOutput.psd";
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath))
{
TextLayer layer = (TextLayer)image.Layers[2];
ITextPortion[] portions = layer.TextData.Items;
portions[0].Paragraph.Justification = JustificationMode.Center;
layer.TextData.UpdateLayerData();
image.Save(exportFilePath);
}
The following code demonstrates how to get font size for any text portion in the text layer.
[C#]
// Extracted wrong Font size
string filePath = "直播+电商.psd";
var tolerance = 0.001;
using (var image = Image.Load(filePath))
{
int layerIndex = 22;
// Old API (Using the first paragraph font)
PsdImage psdImage = image as PsdImage;
double[] matrix = ((TextLayer)psdImage.Layers[layerIndex]).TransformMatrix;
double baseFontSize = ((TextLayer)psdImage.Layers[layerIndex]).Font.Size;
double fontSize = matrix[0] * baseFontSize;
// Checking the base font size
if (Math.Abs(100.0 - baseFontSize) > tolerance)
{
throw new Exception("Font size was read incorrect");
}
// Checking real font size
if (Math.Abs(88.425 - fontSize) > tolerance)
{
throw new Exception("TransformMatrix was read incorrect");
}
// New API (One text layer may contain any quantity of font sizes)
ITextPortion[] portions = ((TextLayer)psdImage.Layers[layerIndex]).TextData.Items;
ITextStyle style = portions[0].Style;
double fontSizeOfPortion = matrix[0] * style.FontSize;
// Checking the base portion font size
if (Math.Abs(100.0 - style.FontSize) > tolerance)
{
throw new Exception("Font size was read incorrect");
}
// Checking real portion font size
if (Math.Abs(88.425 - fontSizeOfPortion) > tolerance)
{
throw new Exception("TransformMatrix was read incorrect");
}
}
See Also
- class Layer
- namespace Aspose.PSD.FileFormats.Psd.Layers
- assembly Aspose.PSD