Create Raster Mask

Hi,

I need to create a PSD file which suppose to have multiple layers and each layer needs to have a raster mask.
For raster mask I need to set mask from svg or png file as its based path.

I tried below lines but getting this error:
Invalid layer mask parameter (ImageData). Mask data bytes length should be equal MaskRectangle.Width * MaskRectangle.Height properties.

 LayerMaskData layerMask = new LayerMaskDataFull();
 layerMask.MaskRectangle = new Rectangle(0, 0, dto.Width, dto.Height);
 layerMask.ImageData =  mask;
 layer.AddLayerMask(layerMask);

the mask is byte array which parsed from my png file.

Wondering if there is any sample exists.

Thank you

@MoeMollaei

The some examples can be found here Editing raster layer masks in PSD file via API|Documentation

Could you please provide the full working code (with creation or opening the PSD Image).

Unfortunately, I couldn’t find similar example there.

I pushed my code into public repo.
Kindly have a look.

Also, I shared what I wish to achieve here for your reference.

https://drive.google.com/drive/folders/1SAaI9kQJb5YCSoqbW0t3QlJErZ7UVfz8?usp=share_link

@MoeMollaei I created a task: PSDNET-1364. Prepare an example of adding mask or/and improve the API to make it simpler

It will be investigated next week and then you will be texted or will be created a task about improvement of API