I'm currently having an issue where the transparent portion of a PNG is turning gray when I adjust the opacity of the image. The following code replicates the issue I'm having in my application:
Thanks in advance for any help!
MagickImage img = new MagickImage(responseStream);
double opacitySetting = Quantum.Max / (Quantum.Max * 0.5);
img.Alpha(AlphaOption.Set);
img.Evaluate(Channels.Alpha, EvaluateOperator.Set, Quantum.Max / opacitySetting);
MagickImage tiles = new MagickImage(new FileInfo("C:\\bar.png"));
MagickImage canvas = new MagickImage(Color.Transparent, tiles.Width, tiles.Height);
canvas.Composite(tiles, Gravity.Center, CompositeOperator.Atop);
canvas.Composite(img, Gravity.Center, CompositeOperator.Atop);
byte[] bytes = canvas.ToByteArray(MagickFormat.Png);
using (Stream fileStream = File.Create("C:\\foo.png"))
{
fileStream.Write(bytes, 0, bytes.Length);
}
The above produces this image where instead it should look like this (with more transparency in the overlay). Does this have anything to do with this issue?Thanks in advance for any help!