Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello I need bitblt sample with win32 or mfc sample. I will make sprite sheet animation with black-white masking metod. Please help me, I need very very basic masking and animationg sample.
thanks

PS: I was used bitblt with vb6 (srcand - srccopy) but I need c++ version sample
Posted
Comments
pasztorpisti 2-Sep-12 11:13am    
If you need masking then you always have to redraw the background as well before blitting your masked image so you will have to use double buffering to avoid flickering (you always draw to a bitmap instead of the window and then blit the bitmap to the window when all the drawing is ready).
So, you create your bitmap (the backsurface) to draw on and then when you get a WM_PAINT message in your window you start drawing on this bitmap: first you draw the background with a bitblt/SRCCOPY, then you draw the appropriate sprite animation frame like this: http://www.winprog.org/tutorial/transparency.html and then you draw the whole bitmap to your window with bitblt/SRCCOPY. If you need frequent updates then setup a WM_TIMER message for your window with the SetTimer() call and then from your periodically called WM_TIMER event handler you can force a WM_PAINT message by calling InvalidateRect(). I wouldn't use WM_TIMER is the accuracy I needed was beyond 50-100 frame/sec but I think that must be enough for your animation.

 
Share this answer
 
Comments
Sandeep Mewara 2-Sep-12 7:17am    
Comment from OP:
I mean sprite frame animation (not position animation)
It does not matter which application framework you use (MFC or Win32)

You will have to go down to Win32 to do that sprite rendering and animation; yes, you could use some of the MFC wrappers (CDC, GDI+, ... ), but it all come down to Win32.

If know how to use BitBlt with VB, then you should be able to use it in a C/C++ windows application, just google "bitblt c++ mfc windows win32 sample example" and you will find tons of relevant suggestions.

Good luck.

Max.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900