Click to See Complete Forum and Search --> : Own Bitblit Routine


October 17th, 1999, 12:23 PM
Hi there,

I am looking for some code for doing my own bitblitting routine.
Ofcourse not just bitblitting but make routines for different
types of blitting:
* transparency
* alpha blending
* darkening
* multiplying.

etc..

So a transparency call should look like this::

Bool MyTransparentBlit(
HDC hDestDC, int xpos, int ypos,
HDC hSrcDC, int xoffs, int yoffs, int width, int height)
{
// Get bits from DestDC
// Get Bits from source DC
// Mix'em together
// set Bits to dest DC
}

One of the calls that I need are probably GetDIBits, which calls for a bitmap.
Bummer!! In my heading I have only HDC....
Thus time to convert the DC to a bitmap. I've tried some code using a MemDC
and a bitblit and then select a compatible bitmap object into it, giving a handle to the old bitmap...
I tried to do it like this, but a call GetDIBits did not get the bits...
The return value (nr. of scan lines read) returned 0..so some thing went
wrong. (BTW I did not found mutch of info on getDIBIts or SetDIBIts in the mSDN library)...

So...
here's the question...
How do I get a proper handle to the bitmap inside any DC
and
How do i get the bits into the correct array...

BTW...

The bitmap created from the screen DC (in most cases this is the DestDC)
always returns a resolution of 1024x768 using GetDeviceCaps(HORZRES), which
is the screen resolution of my monitor, though it is not the size of the client area of the window it is attached to.. How do I get that area ?

Thanks appreciated..
When the code is ready I will certainly post it so these tricks for transparent
blits (using 9 bitblits or masked blits) are banned to the past...

Greetings and hope to hear from you soon ..
Hans Stevens
loba_loba@hotmail.com

Feng Yuan
October 17th, 1999, 02:12 PM
Create two 24-bit DIB section, each bitblted with
either src or dst image.

Combine them in the way you can, bltblt to
destination DC.

October 18th, 1999, 02:25 AM
OK, but I don't have images, I have DC's...
That's the problem...

November 8th, 1999, 02:17 PM
You won't be able to access the bitmap information if it is being
selected by a DC. Once a DC has selected a bitmap then it will be
locked in memory and all calls to access it's info - like GetDIBits
would fail.

- Pal

Kelly
November 8th, 1999, 02:32 PM
Just my humble opinion, it would seem that you need a better understanding of the inner-workings of the existing bitblt() and related functions and structures because what you ask requires the most fundamental knowledge of these things before moving off to create your own blitter. Bitmaps are objects in memory with a bit buffer that is read/write. DC's are objects with a sort of memory mapped image of screen space with some elementary functions for drawing and blitting. Creating a blitter, you will have to make your OWN method of copying data to the DC from the bitmap, not by using the selectobject for the bitmap.

Additionally, if you're planning on getting any acceptable performance at all, you had better be prepared to code your blitting code in 32 bit assembly code. Have you looked to DirectX to see if what you are interested is already supported (and fully optimized!) by the video driver?

No disrespect intended, just a few things I thought I'd point out.

Regards,
--Kelly