Boy oh Boy - look at this
Ok can anybody tell me why this function fails to copy a sprite from an "offscreen" device context to the main one?
void blit(int destX, //X location on destination surface
int destY, //Y location on destination surface
RECT srcRect, //source RECT for sprite
HDC srcSurf)
{
memcpy( &mainDC + (destY*WINDOW_WIDTH+destX),
&srcSurf+srcRect.top*OFFSCREEN_WIDTH+srcRect.left),
(srcRect.right-srcRect.left)*(srcRect.bottom-srcRect.top));
}
I think it might have something to do with the fact that a HDC is just a pointer to a position in a list of pointers that tell windows everything it needs to know about the GUI Object it''s looking at.
You have to use BltBit (or BitBlt I can not remember the correct way around off the top of my head)
You have to use BltBit (or BitBlt I can not remember the correct way around off the top of my head)
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Use BitBlt() to do what you want!
-------------------------------
That's just my 200 bucks' worth!
..-=gLaDiAtOr=-..
-------------------------------
That's just my 200 bucks' worth!
..-=gLaDiAtOr=-..
BitBlt does not do what I want. It does not have transparency ala Color keying. I do not want to mess around with masks, as that doubles the space I will need in my bitmap files, having a picture AND a mask for each sprite. So I am trying to write my own blitter, and I am starting with a simple memcpy. So back to my original question - how can I get a pointer to the starting address of a DC?
Take a look at the function SetDIBBits, you may be able to do something with it.
by default, a DC "contains" a bitmap object. if you create a memory DC, it only contains a 1x1 monochrome bitmap. so first, you need a bitmap of the correct format to select into the destination dc. then use Get and SetDIBBits to modify the bits of the bitmap (HBITMAP) not the dc.
or something like that, i haven't slept in a while.
good luck,
also, if you're targeting Win98 or Win2K+ then you can use the TransparentBlt gdi function (defined in "wingdi.h").
crazy166
some people think i'm crazy, some people know i am
Edited by - crazy166 on August 17, 2000 12:40:37 AM
by default, a DC "contains" a bitmap object. if you create a memory DC, it only contains a 1x1 monochrome bitmap. so first, you need a bitmap of the correct format to select into the destination dc. then use Get and SetDIBBits to modify the bits of the bitmap (HBITMAP) not the dc.
or something like that, i haven't slept in a while.
good luck,
also, if you're targeting Win98 or Win2K+ then you can use the TransparentBlt gdi function (defined in "wingdi.h").
crazy166
some people think i'm crazy, some people know i am
Edited by - crazy166 on August 17, 2000 12:40:37 AM
Thanks. So I am guessing that there is no way to blit transparent sprites using BitBlt (besides using masks or very, very long functions). I may have to resort to those, but I would rather not. As for TransparentBlt, I tried it, but my version''s of wingdi.h and the lib files are older and do not have the newest Windows 98 and 2000 stuff. Could anybody give me a link to download the newest Windows GDI includes and libraries? And still, does anybody know why my pointer to the DC fails to give me its address (or what else is wrong with the function)?
Mike, try this one: HOWTO: Transparent Bitmaps
-------------------------------
That's just my 200 bucks' worth!
..-=gLaDiAtOr=-..
-------------------------------
That's just my 200 bucks' worth!
..-=gLaDiAtOr=-..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement