Page 1 of 1

From .NET Samples - UsingColors() - Not Expected Result

Posted: 2018-03-11T12:54:55-07:00
by GoRoovy
Hi! Using VB Web Express 2012 & thru NuGet, added Magick.NET-Q8-AnyCPU. I extracted the UsingColors() code from Magick.NET-master samples. I then commented out the sections for Q16 (Blue) and With transparency (Red)...they won't compile with Q8. That left the code for Q8 (Green). I then added an image.Write statement after the Q8 code to put the output to a png file. Everything ran just fine....except the output image looks just the same as the input image. I was expecting a green background...but no...still white. By the way...I am using the Snakeware.png as the input image also taken from the samples code. So...the only additional code I added was the image.write. What am I missing that prevents the code from working properly & changing the background to green??? Any assistance would be greatly appreciated. Thanks!

The added statement: image.Write(ip_Path + "Colors01.png");

Re: From .NET Samples - UsingColors() - Not Expected Result

Posted: 2018-03-11T13:28:27-07:00
by dlemstra
The code doesn't really do anything it just demonstrates the various ways you can use colors.

Re: From .NET Samples - UsingColors() - Not Expected Result

Posted: 2018-03-11T13:42:45-07:00
by GoRoovy
WOW...that was a quick answer/reply. :lol: Thank You!!!
But wait....is it possible to turn that png's background from white to green???
If so...could you give me a hint on what the code would look like??

Re: From .NET Samples - UsingColors() - Not Expected Result

Posted: 2018-03-11T14:04:04-07:00
by dlemstra
You can use the `Opaque` method in combination with `ColorFuzz` to change colors in an image. But that won't really work with this image because the color that you think is white is actually transparent.

Re: From .NET Samples - UsingColors() - Not Expected Result

Posted: 2018-03-11T14:22:03-07:00
by GoRoovy
Again....a quick reply/answer.
I found a 2-line code/solution that accomplished the background color change:

image.ColorAlpha(new MagickColor("#0f0"));
image.Write(ip_Path + "Colors01.png");

The solution was provided by you in the Stack Overflow forum in Jul 2015:
https://stackoverflow.com/questions/315 ... magick-net
The key was knowing that the background was not white...but transparent.

Thanks for your assistance & patience!!!!