Is there a way to use black-and-white images in a PDF as transparency masks for vector content? I know that I can use
\pgfdeclaremask{maskname}{maskfile}
\pgfimage[mask=maskname]{imagefile}
for hard (1-bit) or soft transparency masks, but only with raster images maskfile and imagefile of the same dimension.
If I understand correctly, that is only a requirement of TikZ/PGF, not PDF. At least I'm sure that PDF allows bitmap stencils of different pixel size over other bitmap images (that's what Xerox copiers do for scans to PDF).
However, is there a way to do the equivalent of
\pgfdeclaremask[maskname]{maskfile}
\begin{tikzpicture}
\fill[mask=maskname,color=somecolor] (0,0) rectangle (100,100);
\end{tikzpicture}
to have the opaque parts of the mask drawn in somecolor, or even a way to mask arbitrary content with an alpha channel taken from a grayscale picture?
In case it matters, I'm currently using LuaLaTeX, but that's not a strict requirement.
\begin{tikzfadingfrompicture}[name=mask] \node[fill=transparent!0, draw=none, inner sep=0pt] {\pgfimage{img}}\end{tikzfadingfrompicture}...\path[scope fading=mask, fit fading=false, <fading transform={...}>]; \fill[color=<color>] <coords> rectangle <coords>;– akobel Mar 01 '16 at 12:57