public override Bitmap DrawBitmap(OrbitMap m, RenderOptions rp, CalculationOptions co, Constraints[] orbitConstraints)
        {
            Bitmap b = new Bitmap(rp.CanvasWidth, rp.CanvasHeight, PixelFormat.Format32bppRgb);
            BitmapData bd = b.LockBits(new Rectangle(0, 0, rp.CanvasWidth, rp.CanvasHeight), ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);

            uint maxIter = m.Max(o => o.Iterations);

            foreach (Orbit o in m)
            {
                if (o.X >= 0 && o.X < b.Width &&
                    o.Y >= 0 && o.Y < b.Height)
                {
                    uint gray = ColorFunc(o.Iterations, co.IterationCount);

                    Marshal.WriteInt32(bd.Scan0 + o.Y * bd.Stride + o.X * 4,
                                       unchecked((int)((gray << 24) | (gray << 16) | (gray << 8) | gray)));
                }
            }

            b.UnlockBits(bd);
            return b;
        }
        public unsafe override Bitmap DrawBitmap(OrbitMap m, RenderOptions rp, CalculationOptions co, Constraints[] orbitConstraints)
        {
            Bitmap b = new Bitmap(rp.CanvasWidth, rp.CanvasHeight, PixelFormat.Format32bppRgb);
            BitmapData bd = b.LockBits(new Rectangle(0, 0, rp.CanvasWidth, rp.CanvasHeight), ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);

            uint maxIter = m.Max(o => o.Iterations);

            uint* pixels = (uint*)bd.Scan0.ToPointer();
            foreach (Orbit o in m)
            {
                if (o.X >= 0 && o.X < b.Width &&
                    o.Y >= 0 && o.Y < b.Height)
                {
                    uint gray = ColorFunc(o.Iterations, co.IterationCount);

                    pixels[o.Y * bd.Stride / 4 + o.X] = (gray << 24) | (gray << 16) | (gray << 8) | gray;
                }
            }

            b.UnlockBits(bd);
            return b;
        }
示例#3
0
 public abstract Bitmap DrawBitmap(OrbitMap m, RenderOptions rp, CalculationOptions co, Constraints[] orbitConstraints);
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Colorizer c = colorizers[ci++ % colorizers.Count];

            CalculationOptions opt = new CalculationOptions(pictureBox1.Width, pictureBox1.Height, 100);
            opt.BulbChecking = true;
            opt.OrbitLength = 0;

            RenderOptions rp = new RenderOptions() { CanvasWidth = pictureBox1.Width, CanvasHeight = pictureBox1.Height };

            OrbitMap m = calc.Calculate(opt);
            Bitmap b = c.DrawBitmap(m, rp, opt, null);

            pictureBox1.Image = b;
        }