/// <summary> /// Creates an instance of this class /// </summary> private HeatLayer() { ZoomMin = Double.NaN; _bitmaps = GenerateDots(); HeatColorBlend = Fire; _opacityMax = 0.7; _opacityMin = 1f; }
/// <summary> /// Creates an instance of this class /// </summary> private HeatLayer() : base(new Style(), new NullRenderer()) { ZoomMin = Double.NaN; _bitmaps = GenerateDots(); HeatColorBlend = Fire; _opacityMax = 0.7; _opacityMin = 1f; }
private static void Colorize(Bitmap image, ColorBlend heatPalette, float f) { if (f < 0) { f = 0; } if (f > 1) { f = 1; } var imageData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb); var imageStride = imageData.Stride; var imageScan0 = imageData.Scan0; for (var y = 0; y < image.Height; y++) { var buffer = new byte[imageStride]; System.Runtime.InteropServices.Marshal.Copy(imageScan0 + y * imageStride, buffer, 0, imageStride); for (var x = 0; x < image.Width * 4; x += 4) { var colorIndex = (255 - buffer[x + 2]) / 255f; var color = heatPalette.GetColor(colorIndex); var alpha = Convert.ToInt32(255f * (color.A / 255f) * (buffer[x + 3] / 255f) * f); color = Color.FromArgb(alpha, color); buffer[x + 3] = color.A; buffer[x + 2] = color.R; buffer[x + 1] = color.G; buffer[x + 0] = color.B; } System.Runtime.InteropServices.Marshal.Copy(buffer, 0, imageScan0 + y * imageStride, imageStride); } image.UnlockBits(imageData); }
private static void Colorize(Bitmap image, ColorBlend heatPalette, float f) { if (f < 0) f = 0; if (f > 1) f = 1; var imageData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb); var imageStride = imageData.Stride; var imageScan0 = imageData.Scan0; for (var y = 0; y < image.Height; y++) { var buffer = new byte[imageStride]; System.Runtime.InteropServices.Marshal.Copy(imageScan0 + y * imageStride, buffer, 0, imageStride); for (var x = 0; x < image.Width * 4; x += 4) { var colorIndex = (255 - buffer[x+2]) / 255f; var color = heatPalette.GetColor(colorIndex); var alpha = Convert.ToInt32(255f * (color.A / 255f) * (buffer[x+3] / 255f) * f); color = Color.FromArgb(alpha, color); buffer[x + 3] = color.A; buffer[x + 2] = color.R; buffer[x + 1] = color.G; buffer[x + 0] = color.B; } System.Runtime.InteropServices.Marshal.Copy(buffer, 0, imageScan0 + y * imageStride, imageStride); } image.UnlockBits(imageData); }