PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Translucent JPEG images
http://forum.pdfsharp.de/viewtopic.php?f=2&t=889
Page 1 of 1

Author:  fogbank [ Sat Sep 26, 2009 8:56 pm ]
Post subject:  Translucent JPEG images

Hi,
I need to find a way to add a translucent JPEG image to a PDF. Basically, the image has to be drawn semi-transparently on top of whatever is "under" it. I tried to convert it to PNG, to get alpha channel support, but the resulting PDF becomes too large for this to be a satisfying solution.
I know that PDF >= 1.4 supports something like this feature. I was thinking that, maybe, I could load the JPEG image in a PdfImage object and use an equally sized soft mask filled with the alpha value I want, but I don't know if this is the best solution and I cannot even figure out how to add a PdfImage object to a page and how to position it. So far, I've used only PdfSharp's high-level functions.

I'm using the GDI+ build of PdfSharp 1.30.

Could someone help me?
Thanks in advance.

Author:  fogbank [ Mon Sep 28, 2009 10:50 pm ]
Post subject:  Re: Translucent JPEG images

Ok, after reading some of the PDF specifications, my understanding is that the best way to accomplish what I need to do (draw a bitmap image with a constant alpha factor) is to save the current graphics state, set the alpha default value for nonstroke operations, draw the image and pop the graphics state.

I'd like to know if this is the most sensible way to do it, and I'd like to have a couple of lines of sample code to modify the graphics state and set the transformation matrix without using the high-level XGraphics object.

Thanks in advance.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/