Q:
Hi pdfTron Support, We would like to draw custom annotations into PDFs, similar to what you do in the OnPaint() method of the MyPdfView example.
What I have done so far as a test looks like this:
The first highlight is a “real” PDF highlight drawn by PDFNet itself. The second highlight is a custom highlight which I add in OnPaint(). As you can see, the yellow highlight (with an Alpha of 128) “blurs” the black text because it is drawn over it.
My question is: How can I paint a custom highlight behind the PDF text? As much as I can see, OnPaintBackground() and the position of base.OnPaint() have no effect whatsoever.
A:
First of all, I assume you have got an access to the buffer rendered by PDFNet and you now want to draw the custom annotations on top of it.
The buffer for each pixel has four components (BGRA, under windows). I guess your result is generated using Normal blend mode. And in order to achieve the result you mentioned, you need to use Multiply blend mode. When Multiply is used, the result colour is always at least as dark as either of the two constituent colours. In this particular close, yellow and black will yield black. For more details about Multiply blend mode, please refer to: http://en.wikipedia.org/wiki/Blend_modes