我很想在地图上添加点。不管这张地图上有多少个图钉,每个图钉都会有自己的颜色。我只想改变色调
我正在使用一个看起来像这样的模板 png
我想创建一个函数,当出现新点时,该文件将随机着色。
我该怎么做?
我正在使用下面的代码 - 我无法弄清楚如何在矩阵中抛出随机值以输出任何在色板中间隔足够远的好颜色
private Bitmap ColorMyPin()
{
Image imgPicture = Properties.Resources.green_MarkerBlank;
Bitmap bmp = new Bitmap(imgPicture.Width, imgPicture.Height);
ImageAttributes iaPicture = new ImageAttributes();
ColorMatrix cmPicture = new ColorMatrix(new float[][]
{
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0}, <-- //Hard part where do i throw random() values at
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0}
});
// Set the new color matrix
iaPicture.SetColorMatrix(cmPicture);
// Set the Graphics object from the bitmap
Graphics gfxPicture = Graphics.FromImage(bmp);
// New rectangle for the picture, same size as the original picture
Rectangle rctPicture = new Rectangle(0, 0, imgPicture.Width, imgPicture.Height);
// Draw the new image
gfxPicture.DrawImage(imgPicture, rctPicture, 0, 0, imgPicture.Width, imgPicture.Height, GraphicsUnit.Pixel, iaPicture);
return bmp;
}
后