private void DrawBiomes(Box box, float scalefactor) { Bitmap backGround = new Bitmap((int)(box.Area.Width * scalefactor), (int)(box.Area.Height * scalefactor)); for (int i = 0; i < backGround.Width; i++) { for (int n = 0; n < backGround.Height; n++) { decimal offsetN = (decimal)n / (decimal)backGround.Width * 100; double x = InferiorBoundaryX + Interval / 100 * (double)offsetN; decimal offsetI = (decimal)i / (decimal)backGround.Height * 100; double y = SuperiorBoundaryY - Interval / 100 * (double)offsetI; Color customColor = Zoo.ColorAt(x, y); backGround.SetPixel(n, i, customColor); } } _background = ResizeImage(backGround, box.Area.Width + 5, box.Area.Height + 5); // for override aberration add for exemple 5 }
private unsafe void DrawBiomesUnsafe(Box box, float scalefactor) { Bitmap backGround = new Bitmap(Convert.ToInt32(box.Area.Width * scalefactor), Convert.ToInt32(box.Area.Height * scalefactor)); BitmapData backGroundData = backGround.LockBits(new Rectangle(0, 0, backGround.Width, backGround.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int bytesPerPixel = 3; byte *scan0 = (byte *)backGroundData.Scan0.ToPointer(); int stride = backGroundData.Stride; for (int y = 0; y < backGroundData.Height; y++) { byte *row = scan0 + (y * stride); for (int x = 0; x < backGroundData.Width; x++) { int bIndex = x * bytesPerPixel; int gIndex = bIndex + 1; int rIndex = bIndex + 2; decimal offsetN = (decimal)x / (decimal)backGround.Width * 100; double doubleX = InferiorBoundaryX + Interval / 100 * (double)offsetN; decimal offsetI = (decimal)y / (decimal)backGround.Height * 100; double doubleY = SuperiorBoundaryY - Interval / 100 * (double)offsetI; Color color = Zoo.ColorAt(doubleX, doubleY); row[rIndex] = color.R; row[gIndex] = color.G; row[bIndex] = color.B; } } backGround.UnlockBits(backGroundData); _background = ResizeImage(backGround, box.Area.Width + 5, box.Area.Height + 5); }