Drawing Pixels in WPF

后端 未结 5 896
日久生厌
日久生厌 2020-12-01 06:37

how would I manage pixel-by-pixel rendering in WPF (like, say, for a raytracer)? My initial guess was to create a BitmapImage, modify the buffer, and display that in an Imag

5条回答
  •  旧巷少年郎
    2020-12-01 07:06

    you could place 1X1 Rectangle objects onto a Canvas

      private void AddPixel(double x, double y)
      {
         Rectangle rec = new Rectangle();
         Canvas.SetTop(rec, y);
         Canvas.SetLeft(rec, x);
         rec.Width = 1;
         rec.Height = 1;
         rec.Fill = new SolidColorBrush(Colors.Red);
         myCanvas.Children.Add(rec);
      }
    

    That should be pretty close to what you want

提交回复
热议问题