Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Image transparency and opacity issue.

$
0
0
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:
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!

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>