I have a picture with a black background how to draw it to the screen without the background. What function I must use on GDI?
You need to do two BitBlts..
You also need another bitmap - a mask - which is just black and white.
The first BitBlt will remove the pixels 'behind' the image you actually want to draw - so you blit your mask bitmap using SRCAND (the black parts of the mask will erase the background, and the white parts will leave those pixels as they are.)
Then you can blit your actual image using SRCPAINT - the pixels of the background that are now black will simply take the pixels from your image, and the parts of your image that are black will not be drawn onto the background.
For later versions of windows, I'm pretty sure there's another function for this os you don't have to use the two bitmaps. But this way works on all versions of windows :wink
There's also maskblt which does the same thing, except the mask bitmap must be monochrome and the purpose of the white and black parts is the other way around.)
I have tried it. Im using the SRCAND but the picture still have the blach background and my picture color become the color behind it. What is wrong?
An example might be easier to understand :U
[attachment deleted by admin]
Im still did not get it. This is my try but for real time process it very slow.
[attachment deleted by admin]
I don't see how I can make it any easier to understand.
From my example, in reference to what I think you're trying to do:
- pic1.bmp = 093070B.jpg
- pic2.bmp = earth000?.jpg
- mask.bmp = <none>
So, you would need to make a 'mask' image - which is the one you draw first, before drawing your earth image.
The mask image will be a black circle (exactly an outline of the earth jpeg images) on a white background.
You will have some problems with drawing from the jpeg images because 'black' is not all the same as 000000h - some parts are very dark, but not BLACK.
Also, I don't know how fast this method will be either. You should probably look into using directdraw/direct3d.
:U Hai, thanks I understand it now. So I must made another bitmap as a mask. A black mask right with white background.
Here it is. Please test it and tell me is something wrong.
http://www.geocities.com/realvampire2001/Peta.zip
1. No source code ::)
2. No mask image
I can't see when my eyes are closed :wink
So it mean its working right? You want the source? Off course I will post it sometime. Im not at home, Im using linux now.
No, it's not working right.
But I can't help you or find what's wrong without knwoing what is happening - so I need to see the source code.
Also, there was no mask image, so that means you're not using one?
OKay I separated the file now. This computer cannot open a .zip.
Modified by hutch--
Farabi, please don't try and post code that is so large, put it in a zip file and attach it instead. The posting was so large that it messed up the forum display and it was incomplete due to truncation.
Same comment here. 800 lines of code id far to large to post directly in the forum, place it in a zip file.
You are rigth about something is wrong. I load 72 frame but not loaded corectly, sometime it cannot load and some frame missing. I dont know why.
I think you're trying to do too many things at one time.
You should try to make a simple program first, and then add each piece - one each time. So you can make sure that each bit works, before you add the next.
Soo..
1. do simple window with background image
2. do image+mask on top of the background
3. do animation with image
4. .....
This way makes it easier to understand and see where the problems are. Trying to swim through too much code at once just ends in confusion :wink
THanks you are rigth. My windows memory limited to 200 MB. The swap seems too less. Only load a picture it can but too many the memory is inavailable. I dont know what about GlobalLock function, maybe it can use much than 200 MB.