Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BitBlt SRCAND and PDF

137 views
Skip to first unread message

phil oakleaf

unread,
Feb 22, 2010, 7:46:20 AM2/22/10
to
I am using BitBlt with SRCAND and everything works perfectly on screen
and the normal printers.

But, when I print to a PDF driver the SRCAND flag seems to be ignored so
the result is wrong.

(I have read elsewhere that PDF does not handle SRCAND)

Does anyone have any ideas how to handle this?

Many thanks
Phil

Joseph M. Newcomer

unread,
Feb 22, 2010, 8:25:54 AM2/22/10
to
I suspect that the PDF not handling SRCAND is correct.

You would have to say more about what you are trying to accomplish, but the most likely
thing you need to do is to create your bitmap using whatever combination of BitBlt
operations you want, then use that final, resulting BitBlt as the output to the PDF file.

Similar problems arise when using alpha blending with most printer drivers.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

phil oakleaf

unread,
Feb 22, 2010, 9:14:27 AM2/22/10
to
I have an HBITMAP created from a B/W Tiff (up to 12000x9000 pixels) and
over this we display a set of solid filled shapes.

On screen I first draw the shapes in solid colour
then bitBlt the HBITMAP over using the following

int mode=cdc->SetStretchBltMode( HALFTONE );
cdc->StretchBlt(X1,Y1,X2-X1,Y2-Y1,&tDc,sx1,sy1,(sx2-sx1),(sy2-sy1),SRCAND);
cdc->SetStretchBltMode( mode);

works great on screen and my OfficeJet printer

On PDF the HBITMAP blocks out the coloured shapes

Hope this helps
Phil

Joseph M. Newcomer

unread,
Feb 22, 2010, 11:07:55 AM2/22/10
to
Sadly, far too many printer drivers fail to handle a lot of interesting cases.

Adobe has not been among the best-and-brightest in the world, either. I had a problem
like this some years ago, where I had a PowerPoint slide with a bitmap background, on
which I was putting text. None of the text printed. When I called to report the problem,
I was referred to Adobe, who confirmed that they stupidly "sorted" the output so that
bitmaps were sent down *after* text (thus ignoring ALL Z-order requirements). I was under
the impression they had fixed this defect more than ten years ago, but sometimes stupidity
knows no time limits. And worse still, sometimes comes back, particularly if you are not
using an Adobe driver (Adobe should know better by now, but I've found, in some cases,
independent vendors re-invent the same mistakes).

Since the problem occurred, I do not recall trying to print text on bitmaps, but I'm sure
I have. If so, it has certainly worked. I have not tried anything complex with my
third-party PDF printer driver.

What you want to do *should* work, and if it doesn't, you should feel justified in
reporting it as a serious bug to whomever created the PDF driver.

joe

phil oakleaf

unread,
Feb 22, 2010, 12:09:05 PM2/22/10
to
Thanks for all the info

What I'm doing now is to create a Bitmap and combine the Solid Shapes
and HBITMAP in memory - then BitBlt that image back to the printer.

So I output the solid colours on to the CDC

The instead of just BitBlting the HBITMAP, I first BitBlt the area on
the CDC where the Tif will go into a CBitmap - this should now contain
the solid colours that will be under the TIF.

Then I BitBlt the Tif image over that using SRCAND - this should create
the correct image.

Finally Bitblt the HBITMAP back into the CDC

This works beautifully on screen but on printers and print preview I
either get no colours or a big solid black block

It seems as though the printer CDC does not have my coloured shapes

Is this becuase the Printer CDC works differently to the screen?

Hope this is clear enough

Phil

Joseph M. Newcomer

unread,
Feb 22, 2010, 9:05:24 PM2/22/10
to
If you have a bitmap image which you are BitBlting onto the DC, then a printer driver
*should* work, because all it has to do is take your pixels. It shouldn't care where they
come from or how they are formed.

Print preview is a different animal, and I don't do a lot of print preview work, but it
probably has to do with the DC preparation. In this case, without a simple example to
show it, it may not be possible to help much. But from what you describe, both the print
preview and the printer should work, providing the printer does support bitmaps (most
printers do, but you should use GetDevCaps to make sure your printer can handle bitmaps).

I'm at somewhat a loss as to what to suggest, because it sounds like you are doing all the
right things.
joe

phil oakleaf

unread,
Feb 23, 2010, 2:17:43 AM2/23/10
to
Joe

many thanks for the replies,

This has been one of those situations where rather than solve the
problem I came at it from another another direction and have managed to
find a way that works

thanks again and well done on the award

Phil

steveh2112

unread,
May 25, 2011, 3:33:48 AM5/25/11
to
hi, i have exactly the same problem, i have a program that display music
notation. the notes look great on the screen and printer but the rectangle
around the bitmaps is all fuzzy on the pdf print

my drawing code looks like this
pDC->BitBlt( x,y, w, h, dcMask, 0, 0, SRCAND);
pDC->BitBlt( x,y, w, h, dc, 0, 0, SRCPAINT);

any ideas please? thanks
0 new messages