merge images one with transparent background.. can it done? RRS feed

  • Question

  • User-716936047 posted
    Hi All, I have just started looking into System.Drawing, and have managed to draw an image that I require ( novice programmer :) ) but now I need to grab another image and paste it over the top of the image I have created, the image I am grabbing is an icon as png with a transparent background. The image I am pasting onto will have a solid background colour, that is not known until the page is compiled, which is why I am using a transparent png for the icon that I am pasting on top. Hope this makes sense; the project is a skinnable site based on the user-preferred colours and some of the graphics have icons. Before I start trying to find a method for this, I just wondered if anyone knows if I can actually do it. Thanks in advance Lee
    Friday, November 12, 2004 3:07 PM

All replies

  • User-960547388 posted
    Drawing PNGs on other bitmaps should account for transparency by default. I've done that a number of times. There's nothing special required g.DrawImage(png, 0, 0); DrawImage() makes use of the Alpha component of the Color. hope this helps :)
    Monday, December 6, 2004 4:28 PM
  • User-716936047 posted
    Hi alexdg, Sorry didn’t see your reply, thanks for trying to help. I did get it working in the end and as you say it used the transparency by default which is great the only problem I am having is the PNG is very blurred, I have tried loads to try and fix this but with no luck and so am just about to make a post . I am not a programmer so this is pretty hard going ... but cant beleive how powerfull the GDi is.... it's great ! Thanks again Lee System.Drawing.Image cartIcon = System.Drawing.Image.FromFile(Server.MapPath("shoppingcart.png")); Bitmap objBitmap01 = new Bitmap(390,42 ); Graphics objGraphics01 = Graphics.FromImage(objBitmap01); //objGraphics01.SmoothingMode = SmoothingMode.; objGraphics01.Clear(Color.White); objGraphics01.FillRectangle(new SolidBrush(ColorTranslator.FromHtml(mycolor02)), 10, 0, 370, 2); using(Graphics g = Graphics.FromImage(objBitmap01)) { g.DrawImage(cartIcon, 350, 10); }
    Monday, December 20, 2004 10:49 AM