unipdf icon indicating copy to clipboard operation
unipdf copied to clipboard

[FEATURE] Ability to set masks for creator Image

Open gunnsth opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. For layering images, masks are necessary.

Describe the solution you'd like It should be possible to set a mask for an Image which would basically set the a mask (either a hard/stencil or a soft mask) for that image.

The mask is a matrix of the same dimensions as the image and determined which pixels are actually used when layering.

Hard masks (stencil masks) are binary, whereas soft masks (alpha transparency) can be multi level.

Describe alternatives you've considered This is currently not supported.

There are a few different options for masking discussed in PDF32000_2008 section 8.9.6 (Masked Images) that would be worth investigating further prior to implementation.

  • Stencil mask is a binary mask (transparent/opaque).
  • Specific colors can be masked out
  • SMask is basically an alpha layer

Implementing the SMask might make sense as it is the most flexible although the stencil masks will take less space. It would also be possible to detect if a provided mask uses only 2 levels and then store it as a stencil mask.

Additional context Currently when an image is loaded the alpha data is stored. Would make sense to revisit how this is done.

gunnsth avatar Oct 04 '19 22:10 gunnsth

Related #286 fixes multiple transparency issues. But still useful to be able to set masks.

gunnsth avatar Mar 31 '20 20:03 gunnsth