다음은 내가 찾은 것입니다 :
Image를 서브 클래 싱하는 클래스를 생성했습니다.
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에는 서명되지 않은 int 배열을 픽셀 데이터로 사용하는 WritePixels라는 메서드가 있습니다. 나는 이미지의 소스를 WriteableBitmap으로 설정했다. 이제 픽셀 데이터를 업데이트하고 WritePixels를 호출하면 이미지가 업데이트됩니다.
저는 비즈니스 포인트 데이터를 포인트 목록으로 별도의 개체에 저장합니다. 목록에서 변환을 수행하고 변환 된 점으로 픽셀 데이터를 업데이트합니다. 이렇게하면 기하학 객체의 오버 헤드가 없습니다.
참고로, 나는 포인트를 Bresenham의 알고리즘이라는 것을 사용하여 그린 선으로 연결합니다.
이 방법은 매우입니다. 눈에 띄는 지체없이 마우스 움직임에 대한 응답으로 약 50,000 포인트 (및 연결 라인)를 업데이트하고 있습니다.
픽셀 단위로 작업하는 경우 WPF가 정말로 필요합니까? – MusiGenesis
나머지 응용 프로그램의 컨텍스트는 WPF입니다. – Klay