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

New Post: How to Change the color of each pixel in a image

$
0
0
Hi,
I also need to change pixel by pixel value, but applying the Write method to the WritablePixelCollection does not work. By that, i mean the final picture is the same as the original.

Picking up the KevinlsCoding example:
class Program
{
    static void Main(string[] args)
    {
        MagickImage image = new MagickImage();
        image.Read("C:\\.....\\test1.png");
        WritablePixelCollection writablePixels = image.GetWritablePixels();
        foreach (Pixel p in writablePixels) {
            p.SetChannel(0, <some random number between 0 and max of ushort>);
        }
        writablePixels.Write();
        image.Write("C:\\.....\\test2.png"); //this gives the same image as the original with no transformation on pixel color.
    }
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles