public bool LoadMaskImage { get; set; }
@property (nonatomic, assign) BOOL loadMaskImage;
LoadMaskImage # get and set (CodecsPsdLayerInfo)
true load to load the mask image when loading PSD files with RasterCodecs.LoadPsdLayer; otherwise, false.
When the value of this property is true and you call RasterCodecs.LoadPsdLayer to load a PSD file, then the transparency mask channel image will be in the MaskImage property.
This property is not used when calling RasterCodecs.SavePsdWithLayers to save a PSD file.
Default value is true.
For more information, refer to the FILE FORMATS SPECIFICATION from Adobe.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
public void PsdLayersExample()
{
RasterCodecs codecs = new RasterCodecs();
string[] layerFileNames =
{
Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp"),
Path.Combine(LEAD_VARS.ImagesDir, "Sample2.cmp"),
Path.Combine(LEAD_VARS.ImagesDir, "Sample3.cmp"),
};
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.psd");
// Load the layer images (as pages in 1 image)
RasterImage layersImage = null;
foreach (string layerFileName in layerFileNames)
{
RasterImage layerImage = codecs.Load(layerFileName);
if (layersImage == null)
layersImage = layerImage;
else
layersImage.AddPage(layerImage);
}
// Load the image that is made up of all the layers
RasterImage image = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.BgrOrGray, 1, 1);
// Save this image and all the layers
codecs.SavePsdWithLayers(image, destFileName, 0, layersImage, null);
image.Dispose();
layersImage.Dispose();
CodecsImageInfo imageInfo = codecs.GetInformation(destFileName, false);
if (imageInfo.Psd.Layers > 0)
{
int layer = 0;
CodecsPsdLayerInfo layerInfo = new CodecsPsdLayerInfo();
RasterImage layerImage = codecs.LoadPsdLayer(destFileName, 0, CodecsLoadByteOrder.BgrOrGray, layer, layerInfo);
layerInfo.Clipping = 0;
layerInfo.Left = 0;
layerInfo.LoadMaskImage = true;
layerInfo.MaskImage = null;
layerInfo.Name = null;
layerInfo.Opacity = 0;
layerInfo.Top = 0;
string blendModeKey = Encoding.ASCII.GetString(layerInfo.GetBlendModeKey());
Debug.WriteLine("Loaded layer at index {0}, size is {1} by {2}, Blend mode key:{3}", layer, layerImage.Width, layerImage.Height, blendModeKey);
Debug.WriteLine("TransparencyProtected is {0}, Visible is {1}, Obsolete is {2} and Psd5OrLater is {3}",
layerInfo.TransparencyProtected, layerInfo.Visible, layerInfo.Obsolete, layerInfo.Psd5OrLater);
char[] byteArray = "dark".ToCharArray(); //Define Blend Mode Key
layerInfo.SetBlendModeKey(Encoding.ASCII.GetBytes(byteArray));
Debug.WriteLine("Loaded layer at index {0} with updated Blend mode key:{1}", layer, Encoding.ASCII.GetString(layerInfo.GetBlendModeKey()));
layerImage.Dispose();
}
else
Debug.WriteLine("No layers found in this PSD file");
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.