Click to See Complete Forum and Search --> : DIB Handle in VB?


November 22nd, 1999, 09:38 AM
Hi all,

Does anyone know how VB can use a handle to a DIB? My VB app gets a DIB handle back from a DLL which in turn scans an image on a scanner. My ultimate goal is to just print the image; I don't even need to display it (but I can if it makes it easier). Problem is, I don't know how VB can make use of a handle like that.

Any help is greatly appreciated,

Mike

Ravi Kiran
November 23rd, 1999, 03:40 AM
This is just an idea, ok.. even i am not sure if it works.
How abt blitting the DIB bitmap directly into the DC of a Picturebox with an API call like BitBlt? If it works then you can replace the Picturebox DC with the hdc of Printer object ,and in most cases they are interchangabe, you should be able to print it.

You could also check how the API fn GetObject reacts to this handle (in Vb code itself), it may give you a bitmap handle which you can then use to blit the image to a dc.

Tell me if if works.. and if it doesn't work also:-)

RK

November 24th, 1999, 07:41 AM
Yup, BitBlting to the DC of a PictureBox control works. Unfortunately, the bitmap started off monochrome, but after I BitBlted it to the PictureBox it became 24-bit, which wasn't what I wanted. I couldn't find a way to go from 24-bpp to 1-bpp easily, which has been my dilema all along. I finally had to take a hack on this problem, which I hate doing.

Thanks for the suggestion though, much appreciated!

Mike

November 24th, 1999, 07:45 AM
Oh yeah, just for some clarification, it's not a real printer, it's an Adode PDF Writer printer. We need to use monochrome for space considerations. We have literally hundreds of thousands of these PDF files to store, and 50k beats 500k any day :) We don't need it in color to be able to read it.

Later,

Mike