public static void DrawLissajous(Settings settings) { Bitmap bmp = new Bitmap(settings.destinationWidth, settings.destinationHeight); Rectangle rectangle = new Rectangle(0, 0, bmp.Width, bmp.Height); BitmapData bitmapData = bmp.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int x; int y; IntPtr intPtr = bitmapData.Scan0; unsafe { byte* ptr = (byte*)intPtr.ToPointer(); //fixed (byte* ptr = &bitmapData) int stride = bitmapData.Stride; for (int n = 0; n < 31400 * 2; n++) { x = xf(n); y = yf(n); ptr[(x * 3) + y * stride + 2] = 250; //red channel ptr[(x * 3) + y * stride + 1] = 100; //green channel ptr[(x * 3) + y * stride] = 100; //blue channel } } bmp.UnlockBits(bitmapData); bmp.Save(settings.destinationFile); }
static void Main(string[] args) { Settings settings = new Settings(); Core.DrawLissajous(settings); }