ProfK
ProfK

Reputation: 51084

The quickest and easiest way to draw a collection of pixels onto a surface

I have this method that finds all pixels of a particular colour; they will be in a single solid blob. I would like to know if there is a quick and or easy way of drawing them to a surface, e.g. structure them somehow and then just draw that structure to the image surface.

The pixels I'm trying to draw are structured:

public struct Pixel
{
    public Point Position { get; set; }
    public Color Colour { get; set; }
}

Maybe this is wrong, and someone can suggest a better structure for writing into a WriteableBitmap.

Upvotes: 0

Views: 144

Answers (2)

Alexis
Alexis

Reputation: 825

If you need to render them to the visual tree, I suggest you to create a custom control and override the OnRender method. Here you can draw rectangles with 1 px edges. In case of large amount of points this approach has the best performance. If the result is blurred, subtract 0.5 px from the left and top, it should help.

Upvotes: 0

Peter
Peter

Reputation: 38515

My guess is that the WriteableBitmap class provides you with the fastest way of drawing pixels but i have done no test to verify this.

Upvotes: 1

Related Questions