News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Removing unwanted color in GDI?

Started by Farabi, June 24, 2005, 09:47:43 AM

Previous topic - Next topic

Farabi

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?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

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.)
No snowflake in an avalanche feels responsible.

Farabi

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?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

An example might be easier to understand :U


[attachment deleted by admin]
No snowflake in an avalanche feels responsible.

Farabi

Im still did not get it. This is my try but for real time process it very slow.

[attachment deleted by admin]
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

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.
No snowflake in an avalanche feels responsible.

Farabi

 :U Hai, thanks I understand it now. So I must made another bitmap as a mask. A black mask right with white background.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

1. No source code ::)
2. No mask image

I can't see when my eyes are closed :wink
No snowflake in an avalanche feels responsible.

Farabi

 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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

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?
No snowflake in an avalanche feels responsible.

Farabi

#11
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.

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

#12
Same comment here. 800 lines of code id far to large to post directly in the forum, place it in a zip file.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Tedd

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
No snowflake in an avalanche feels responsible.