Пример #1
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            var g = pe.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.Clear(Color.White);

            var bmp      = new Bitmap(Width * 2, Height * 2);
            var lockBmp  = new LockBitmap(bmp);
            var viewport = new ViewPort(bmp.Width, bmp.Height);
            var data     = _fractal.GetFractal(_defaultRange, viewport);

            lockBmp.LockBits();
            for (int x = 0; x < bmp.Width; x++)
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    var n     = data[x, y];
                    var color = Color.White;
                    if (n >= _maxTries)
                    {
                        color = Color.Black;
                    }
                    lockBmp.SetPixel(x, y, color);
                }
            }
            lockBmp.UnlockBits();

            var bmpResized = ResizeImage(bmp, Width, Height);

            g.DrawImage(bmpResized, 0, 0);
            //base.OnPaint(pe);
        }
Пример #2
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            var g = pe.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.Clear(Color.White);

            var bmp = new Bitmap(Width*2, Height*2);
            var lockBmp = new LockBitmap(bmp);
            var viewport = new ViewPort(bmp.Width, bmp.Height);
            var data = _fractal.GetFractal(_defaultRange, viewport);

            lockBmp.LockBits();
            for (int x = 0; x < bmp.Width; x++)
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    var n = data[x, y];
                    var color = Color.White;
                    if (n >= _maxTries)
                        color = Color.Black;
                    lockBmp.SetPixel(x, y, color);
                }
            }
            lockBmp.UnlockBits();

            var bmpResized = ResizeImage(bmp, Width, Height);
            g.DrawImage(bmpResized, 0, 0);
            //base.OnPaint(pe);
        }