Esto es lo que encontré:
he creado una clase que las subclases de Imagen.
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 tiene un método llamado WritePixels, que toma una matriz de enteros sin signo como datos de pixel. Establecí que la fuente de la imagen sea WriteableBitmap. Ahora, cuando actualizo los datos de píxeles y llamo WritePixels, actualiza la imagen.
Guardo los datos del punto de negocios en un objeto separado como una lista de puntos. Realizo transformaciones en la lista y actualizo los datos de píxeles con los puntos transformados. De esta manera no hay sobrecarga de objetos de Geometría.
Solo FYI, conecto mis puntos con líneas dibujadas usando algo llamado algoritmo de Bresenham.
Este método es extremadamente rápido. Estoy actualizando unos 50,000 puntos (y líneas de conexión) en respuesta a los movimientos del mouse, sin retraso notable.
Si está haciendo cosas pixel a pixel, ¿realmente necesita WPF? – MusiGenesis
El contexto del resto de la aplicación es WPF. – Klay