private void DrawColorBar(Graphics g, int x, int y, int width, int height, ColorMap map, string str) { int[,] cmap = new int[64, 4]; switch (str) { case "Jet": cmap = map.Jet(); break; case "Hot": cmap = map.Hot(); break; case "Gray": cmap = map.Gray(); break; case "Cool": cmap = map.Cool(); break; case "Summer": cmap = map.Summer(); break; case "Autumn": cmap = map.Autumn(); break; case "Spring": cmap = map.Spring(); break; case "Winter": cmap = map.Winter(); break; } int ymin = 0; int ymax = 32; int dy = height / (ymax - ymin); int m = 64; for (int i = 0; i < 32; i++) { int colorIndex = (int)((i - ymin) * m / (ymax - ymin)); SolidBrush aBrush = new SolidBrush(Color.FromArgb( cmap[colorIndex, 0], cmap[colorIndex, 1], cmap[colorIndex, 2], cmap[colorIndex, 3])); g.FillRectangle(aBrush, x, y + i * dy, width, dy); } }
private void DrawColorBar(Graphics g, int x, int y, int width, int height, ColorMap map, string str) { int[,] cmap = new int[64, 4]; switch(str) { case "Jet": cmap = map.Jet(); break; case "Hot": cmap = map.Hot(); break; case "Gray": cmap = map.Gray(); break; case "Cool": cmap = map.Cool(); break; case "Summer": cmap = map.Summer(); break; case "Autumn": cmap = map.Autumn(); break; case "Spring": cmap = map.Spring(); break; case "Winter": cmap = map.Winter(); break; } int ymin = 0; int ymax = 32; int dy = height / (ymax - ymin); int m = 64; for (int i = 0; i < 32; i++) { int colorIndex = (int)((i - ymin) * m / (ymax - ymin)); SolidBrush aBrush = new SolidBrush(Color.FromArgb( cmap[colorIndex, 0], cmap[colorIndex, 1], cmap[colorIndex, 2], cmap[colorIndex, 3])); g.FillRectangle(aBrush, x, y + i * dy, width, dy); } }