Image drop shadow

P

Peter Morris

I have a 200x200 PNG file which has an Alpha layer.

What I would now like is a 200x200 image that is completely black, but with
the same alpha mask. This is so that I can use it as a drop shadow behind
the PNG when drawing to a target image.

I cannot see how I can draw to a Graphics without destroying the Alpha. Any
hints?


Thanks

Pete
 
P

Peter Morris

Unfortunately that didn't work.

private void button1_Click(object sender, EventArgs e)
{
Image i =
Image.FromFile(@"C:\Data\CustomerProjects\Inteevo\Projects\AlterEgo\CharacterEditor\Samples\Lady1\Lad__0001.png");
Image shadow = (Image)i.Clone();
Image resultImage = new Bitmap(i.Width, i.Height);
Graphics resultCanvas = Graphics.FromImage(resultImage);
Graphics shadowCanvas = Graphics.FromImage(shadow);

//Need to preserve the alpha in this next line
shadowCanvas.FillRectangle(Brushes.Black, new Rectangle(0, 0, 200, 200));

resultCanvas.DrawImage(shadow, new Point(0, 0));
pictureBox1.Image = resultImage;
}


Does anyone have any ideas?
 

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

Top