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

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
GoRoovy
Posts: 3
Joined: 2018-03-11T12:35:06-07:00
Authentication code: 1152

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

Post by GoRoovy » 2018-03-11T12:54:55-07:00

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");

User avatar
dlemstra
Posts: 1480
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra » 2018-03-11T13:28:27-07:00

The code doesn't really do anything it just demonstrates the various ways you can use colors.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

GoRoovy
Posts: 3
Joined: 2018-03-11T12:35:06-07:00
Authentication code: 1152

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

Post by GoRoovy » 2018-03-11T13:42:45-07:00

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??

User avatar
dlemstra
Posts: 1480
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra » 2018-03-11T14:04:04-07:00

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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

GoRoovy
Posts: 3
Joined: 2018-03-11T12:35:06-07:00
Authentication code: 1152

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

Post by GoRoovy » 2018-03-11T14:22:03-07:00

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!!!!

Post Reply