Click to See Complete Forum and Search --> : Printing a bitmap with alpha channel


Hue
June 11th, 2004, 10:05 PM
I am wanting to print a number of overlapping bitmaps to a printer that does not support the AlphaBlend function. My images have either 0 or 255 as the alpha value.

I have some code that operates on my image, and the current output as bitmaps/pixel arrays. Depending upon the alpha value will take the new pixel from either the source or destination bitmaps. I have tried both CreateDIBSection and GetDIBits, and in both cases I get an array of 0s returned - with no error code.

Theoretically I could generate a bitmap in memory and draw to that, before sending to the printer, but as I would like to use 1200dpi A0 printers this may cause problems.. :)

Is there a better command to get the information from the printer, or even a different algorithum to replace the alphablend function?

Thanks
Hugh Dixon

Takeru Koushirou
August 15th, 2004, 05:27 PM
Hi,

you may want to write your own alpha blend function, but it may take some time. Maybe searching the forums will work.
But one question: When your image have either 0 _or_ 255 as alpha channel, why don't you simply draw the images either opaque or skip drawing them?

Hue
August 15th, 2004, 08:10 PM
The alpha bit being 0 ot 255 is on a per pixel basis, not across the whole image :( so there is no benefit for me there.
I have had a look at writing /copying a function to do my own alphablend, however I am wanting to output to large, hires plotters, so the memory requirements are beyond a 32 bit system. :(
I gather the options available are to break the image into many small sections and do them one at a time, or, use GDIPlus. GDIPlus is less programming effort, although it involves temporary files etc., so that's what I prefer!

Hue

Takeru Koushirou
August 16th, 2004, 04:50 AM
Hmm Ic... GDI+ may increase memory usage due the class overhead, but if it works for you, then it's a good choice.
I just got another idea; with per pixel alpha 255 or 0 bitmap, you have an image with opaque and transparent pixels, defined by your alpha channel and not colors used.
Maybe this will word for your: Create a mask (2bit bitmap) of your image, where every pixel with alpha 255 is set (1) and every pixel with alpha 0 is unset (0) (or the opposite, correct me if I'm wrong). Windows GDI uses this method to draw transparent icons etc. on DCs.
So there are functions which can copy your image quite fast for your (e.g. MaskBlt), using this mask. Browsing the MSDN you will find some examples, I think.
I didn't use this method myself yet, but it's quite fast and easy to use.

MaskBlt Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_229g.asp