public Controller(Bitmap bm, int w, int h) { Surface = bm; maxLength = w * h; // Here it starts System.Drawing.Imaging.BitmapData lockData = Surface.LockBits( new Rectangle(0, 0, Surface.Width, Surface.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create an array to store image data Space s = new Space(w, h); // Use the Marshal class to copy image data Marshal.Copy(lockData.Scan0, s.Cells, 0, maxLength); // Creating palette Gfx.Palette.Map paletteMap = new Gfx.Palette.Map(); paletteMap.setColorStop(0, new ColorStop(0, Color.White)); paletteMap.setColorStop(3, new ColorStop(3, Color.LightSteelBlue)); // Color.Yellow)); paletteMap.setColorStop(10, new ColorStop(10, Color.SteelBlue)); // Color.Lime)); //paletteMap.setColorStop(80, new ColorStop(85, Color.DarkSeaGreen)); // Color.DarkRed)); paletteMap.setColorStop(95, new ColorStop(99, Color.DarkBlue)); //.SaddleBrown)); paletteMap.setColorStop(100, new ColorStop(100, Color.Black)); Calc = new Calc(s, paletteMap); if(!continued && !uploaded) { Calc.Randomize(); } // Copy image data back Marshal.Copy(s.Cells, 0, lockData.Scan0, maxLength); // Unlock image Surface.UnlockBits(lockData); // Here it ends }
//public Controller (Bitmap bm, int w, int h, Map paletteMap) public Controller(Bitmap bm, int w, int h, List<Gfx.Palette.GradientEditor.GradientStop> paletteMap) { Surface = bm; maxLength = w * h; // Here it starts System.Drawing.Imaging.BitmapData lockData = Surface.LockBits( new Rectangle(0, 0, Surface.Width, Surface.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create an array to store image data Space s = new Space(w, h); // Use the Marshal class to copy image data Marshal.Copy(lockData.Scan0, s.Cells, 0, maxLength); Calc = new Calc(s, paletteMap); if(!continued && !uploaded) { Calc.Randomize(); } // Copy image data back Marshal.Copy(s.Cells, 0, lockData.Scan0, maxLength); // Unlock image Surface.UnlockBits(lockData); // Here it ends }