private unsafe void Redraw(EditBitmap image, Generator g) { var w = image.Width; var h = image.Height; var span = new Span <double>(new double[w * h]); g.Fill(span, w, h); for (var i = 0; i < w * h; i++) { var c = (byte)(255 * span[i]); image.ImageBytePtr[i * 3 + 0] = c; image.ImageBytePtr[i * 3 + 1] = c; image.ImageBytePtr[i * 3 + 2] = c; } //for (var x = 0; x < w; x++) ////Parallel.For(0, w, new ParallelOptions { MaxDegreeOfParallelism = 32 }, (x) => // { // for (var y = 0; y < h; y++) // { // //TODO // //var p = y * w + x; // //var v = g.Perlin((double)x / (double)w * ((double)Zoom / 10D), (double)y / (double)h * ((double)Zoom / 10D), 0); // //var c = (byte)(255D * v); // //image.ImageBytePtr[p * 3 + 0] = c; // //image.ImageBytePtr[p * 3 + 1] = c; // //image.ImageBytePtr[p * 3 + 2] = c; // } // } //); image.Invalidate(); }
public void UpdateImageSize(int x, int y) { if (x == 0 || y == 0) { return; } Image1D?.Dispose(); Image1D = new EditBitmap(x, y, PixelFormats.Bgr24); Image2D?.Dispose(); Image2D = new EditBitmap(x, y, PixelFormats.Bgr24); Image3D?.Dispose(); Image3D = new EditBitmap(x, y, PixelFormats.Bgr24); Redraw(); }