Piotr Łużecki
Piotr Łużecki

Reputation: 1041

Changing pixels in Image

I have program in which i want to do some graphic algorithms. I found some code snippets for C# that works on bitmaps. To change pixel or something like that do i have to convert image to bitmap first or is there some methods to change pixels in Image? Something like image1.SetPixel(29,201, color1); ?

Upvotes: 0

Views: 4614

Answers (1)

Colin Smith
Colin Smith

Reputation: 12530

You can use the WriteableBitmap class to create a bitmap whose pixels you can modify.

You can then set that Bitmap as the Source for an Image element.

There's a 3rd party library which can help working with WriteableBitmaps more natural i.e. SetPixel and GetPixel methods instead of having to calculate offsets to the pixel data in the buffer.

Upvotes: 3

Related Questions