Big problem Overlaying two bitmaps

J

James Dean

I have 2 1bppindexed bitmaps and i want to combine both together. I
converted both to 24bpp then tried to combine them but it didnt work. If
possible i want to be able to draw one bitmap directly on top of the
other and would be really good if i only had to use one 24bpp bitmap to
do this.Below is a way to map draw a 1bpp bitmap onto a 24bpp
one.....would it be possible to draw my second bitmap on the same
one?.....some pixels overlap as well so i need to set a value for those
pixels too.....any ideas?
Bitmap onebit=(Bitmap)Image.FromFile("theimagefile");
Bitmap bm=new Bitmap(onebit.Width, onebit.Height,
PixelFormat.Format24bppRGB);
Graphics g=Graphics.FromImage(bm);
g.DrawImage(onebit,new
Rectangle(0,0,onebit.Width,onebit.Height),0,0,onebit.Width,onebit.Height
,Gra
phicsUnit.Pixel);
g.dDispose();
 
G

Guest

Are you trying to overlap two images so that one shows thru the other - a
trick with the image's alpha property?
 
G

Guest

Hi James,

That's pretty simple. :)

1. First create the intial bitmap object based on the actual image.
2. Now create a new bitmap object based on the second image. Apply a
ColorMatrix setting the required value of alpha, and then draw this bitmap
upon the first bitmap using the appropriate overload of the DrawImage method.

There is an article on using implementing the apha effect which would give
you a good idea on using the colormatrix etc. @ codeproject:
http://www.codeproject.com/cs/media/alphafx.asp

PS: I wonder whether you will miss this post :(..sorry i had been off to sleep

HTH,
Rakesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Scrolling bitmap problem 1

Top