は、ここで私が見つけたものです:
は、私がイメージをサブクラスクラスを作成しました。
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にはWritePixelsというメソッドがあり、このメソッドは符号なしintの配列をピクセルデータとして受け取ります。イメージのソースをWriteableBitmapに設定しました。今、ピクセルデータを更新してWritePixelsを呼び出すと、イメージが更新されます。
私は、ビジネスポイントデータを別のオブジェクトにポイントリストとして保存します。リスト上で変換を実行し、変換された点でピクセルデータを更新します。この方法では、ジオメトリオブジェクトからのオーバーヘッドはありません。
私はポイントを、ブレーゼンハムのアルゴリズムと呼ばれるものを使って描いた線で結びます。
この方法は、極端にです。マウスの動きに対応して、約5万ポイント(および接続ライン)を更新しています。
ピクセル単位の処理を行う場合は、実際にWPFが必要ですか? – MusiGenesis
残りのアプリケーションのコンテキストはWPFです。 – Klay