troubleshooting Question

Overylaying bitmaps / images in C# .NET 2.0

Avatar of ChrisMDrew
ChrisMDrew asked on
.NET ProgrammingC#Editors IDEs
5 Comments1 Solution893 ViewsLast Modified:
Is it possible to overlay an image on top of another image and then be able to use the resultant image (preferably in memory) within say a tree control?

I found another article and got most of the way and then got stuck as it appears that the Grapghics.Save method is a bit limited in .NET 2.0.  My code so far is shown below - I guess that this would work in .NET 3.5 but is there a way to do this using .NET 2.0?
Bitmap baseImage = IconMapping.LoadIcon(forAsset.Icon, IconMapping.ICONSIZE.small);	
System.Drawing.Graphics graphics = Graphics.FromImage(baseImage);
 
// Now add on (any) overlays 
Bitmap reauditImage = Properties.Resources.asset_reaudit;
graphics.DrawImage(reauditImage, new Point(0, 9));
Bitmap agentImage = Properties.Resources.AuditAgent_stopped_16;
graphics.DrawImage(agentImage, new Point(0, 0));
 
// Recover the image from the Graphics object by saving it to a memory stream
MemoryStream ms = new MemoryStream();
graphics.Save(ms, ImageFormat.Bmp);
 
// ...then load a bitmap from the stream
Bitmap displayImage = new Bitmap(ms);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros