Drawing a bitmap to a bitmap

Nate Bross

Well-known member
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
I am trying to to a manual Double Buffer in vb.net. I have several bitmap objects, and I would like to draw each of them onto a single bitmap object, then finally draw that to the form. There is a reason for my madness, I am developing for the PocketPC and I cannot get Me.SetStyle to work. I am kind of confused with the syntax of how to do that. If someone could give a small example drawing two seprate bitmap objects onto a third. C# code is okay, I can convert but Visual Basic would be more desirable. Thanks inadvance.
 
Not sure for a pocket PC, but heres code for drawing a bunch of bitmaps to a bitmap and then drawing that bitmap to the form for a windows app.

Code:
dim formg as graphics
dim g as graphics
dim backbitmap as bitmap
dim bitmap1 as bitmap
dim bitmap 2 as bitmap

private sub form1_load(dfjkasdjf)dsfad

formg = me.creategraphics
backbitmap = new bitmap(form1.width,form1.height)
^ Set the size of the bitmap
g = graphics.fromimage(backbitmap)
bitmap1 = new bitmap("C:\location\of\bitmap1.bmp")
bitmap 2 = new bitmap("C:\location\of\bitmap2.bmp")

end sub

private sub form1_paint(dfasdfasdf)dafsd or any other sub for that matter

g.drawimage(bitmap1,50,50) bitmap, x location, y location
g.drawimage(bitmap2,12,70)

formg.drawimage(backbitmap,0,0)

end sub
 
I use this method all of the time to draw my pictures:
I have discussed it (the method) here:
http://iceplug.vwebservices.com/cngdi3.htm

But, what you do is you have two bitmaps and a graphics object.
Bitmap backup;
Bitmap somepic;
Graphics gfx;

somepic = new Bitmap("filename.ext");
backup = new Bitmap(width, height);
gfx = Graphics.FromImage(backup);

To draw somepic to backup:
gfx.DrawImage(somepic, 0, 0);
:)
 
I dont know if I should make a new thread or not, I doubt it. I was wondering is there a way to draw a bitmap transparently? IE. I have a bitmap with a black background and I want any black to show up transparently but the rest of my image to display at full opacity?
 
Back
Top