Ecco cosa ho trovato:
ho creato una classe che le sottoclassi immagine.
public class MyImage : Image {
// the pixel format for the image. This one is blue-green-red-alpha 32bit format
private static PixelFormat PIXEL_FORMAT = PixelFormats.Bgra32;
// the bitmap used as a pixel source for the image
WriteableBitmap bitmap;
// the clipping bounds of the bitmap
Int32Rect bitmapRect;
// the pixel array. unsigned ints are 32 bits
uint[] pixels;
// the width of the bitmap. sort of.
int stride;
public MyImage(int width, int height) {
// set the image width
this.Width = width;
// set the image height
this.Height = height;
// define the clipping bounds
bitmapRect = new Int32Rect(0, 0, width, height);
// define the WriteableBitmap
bitmap = new WriteableBitmap(width, height, 96, 96, PIXEL_FORMAT, null);
// define the stride
stride = (width * PIXEL_FORMAT.BitsPerPixel + 7)/8;
// allocate our pixel array
pixels = new uint[width * height];
// set the image source to be the bitmap
this.Source = bitmap;
}
WriteableBitmap ha un metodo chiamato WritePixels, che accetta una matrice di unsigned come dati pixel. Ho impostato la fonte dell'immagine come WriteableBitmap. Ora, quando aggiorno i dati dei pixel e chiamo WritePixels, aggiorna l'immagine.
Memorizzo i dati del punto di business in un oggetto separato come Elenco di punti. Eseguo le trasformazioni sulla lista e aggiorno i dati dei pixel con i punti trasformati. In questo modo non c'è un sovraccarico dagli oggetti Geometry.
Solo FYI, collego i miei punti con linee tracciate usando qualcosa chiamato algoritmo di Bresenham.
Questo metodo è estremamente veloce. Sto aggiornando circa 50.000 punti (e linee di collegamento) in risposta ai movimenti del mouse, senza alcun ritardo evidente.
Se si stanno facendo cose pixel per pixel, hai davvero bisogno di WPF? – MusiGenesis
Il contesto del resto dell'app è WPF. – Klay