我有一个pdf文档,其背景是彩色(红色rgb)矩形,然后应用一个图像(rgb图像),其中包含另一个图像作为蒙版(单色)。
我找不到使用cairo库的正确运算符。
你能给我一些提示吗?
我做了以下事情:
//load the image from file
image = cairo_image_surface_create_from_png(".\image.png");
image_width = cairo_image_surface_get_width(image);
image_height = cairo_image_surface_get_height(image);
cairo_set_source_surface(cr, wndImage, 0, 0);
//create a rectangle and color with red
cairo_rectangle(cr, 0, 0, w, h);
cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
cairo_fill(cr);
cairo_paint(cr);
//load the mask from file and applied the image and mask to the destination
mask = cairo_image_surface_create_from_png(".\mask.png");
cairo_set_source_surface(cr, image, 0, 0);
cairo_mask_surface(cr, mask, 0, 0);
cairo_paint (cr);
pdf包含以下内容:
5 0 obj
<<
/ImageMask true
/Type/XObject/Subtype/Image
/BitsPerComponent 1
/Width 2487
/Height 3512
/ColorSpace/DeviceGray
/DecodeParms<</Columns 2487/K -1>>/Filter/CCITTFaxDecode /Length 17518>>
6 0 obj
<<
/Mask 5 0 R
/Type/XObject/Subtype/Image
/BitsPerComponent 8
/Width 1244
/Height 1756
/ColorSpace /DeviceRGB
/Filter/DCTDecode /Length 162581>>
7 0 obj << /Length 107>> stream
1 0 0 rg
0 -3.12 595 846 re
f
q
597.12 0 0 842.88 0 0 cm
/I2 Do Q 0 g 0 G 0 Tr 0 Tc 0 Tw 100 Tz 1 w [] 0 d endstream endobj