我正在使用C#和WinForms开发一个应用程序,具有GMap.NET个库.
有没有人知道怎么把 map 上的dark mode设定下来?
我目前使用的是OpenStreet map :
map.MapProvider = OpenStreetMapProvider.Instance
个
我看了文件,但什么也没找到.在使用Google map时,可以在css中设置 colored颜色 参数,但我没有找到直接用C#定义css或主题的方法.
我正在使用C#和WinForms开发一个应用程序,具有GMap.NET个库.
有没有人知道怎么把 map 上的dark mode设定下来?
我目前使用的是OpenStreet map :
map.MapProvider = OpenStreetMapProvider.Instance
个
我看了文件,但什么也没找到.在使用Google map时,可以在css中设置 colored颜色 参数,但我没有找到直接用C#定义css或主题的方法.
GMap.NET提供了三种预定义的呈现模式:
[GMapControl].NegativeMode
[GMapControl].GrayScaleMode
这些渲染模式使用ColorMatrix对象来定义每个通道的 colored颜色 量.
它还提供了通过设置[GMapControl].ColorMatrix
属性来指定自定义ColorMatrix的方法.
倒置矩阵~如下所示:
var matrixInverted = new ColorMatrix(new float[][] {
new float[] { -1, 0, 0, 0, 0},
new float[] { 0, -1, 0, 0, 0},
new float[] { 0, 0, -1, 0, 0},
new float[] { 0, 0, 0, 1, 0},
new float[] { 1, 1, 1, 0, 1}
});
灰度矩阵是这样的(我的解释是):
var matrixGray = new ColorMatrix(new float[][]
{
new float[] { .2126f, .2126f, .2126f, 0, 0 },
new float[] { .7152f, .7152f, .7152f, 0, 0 },
new float[] { .0722f, .0722f, .0722f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 1, 1, 1, 0, 1 }
});
如果负片模式不是您想要的,您可以反转灰度ColorMatrix的 colored颜色 :
var matrixGrayInverted = new ColorMatrix(new float[][]
{
new float[] { -.2126f, -.2126f, -.2126f, 0, 0 },
new float[] { -.7152f, -.7152f, -.7152f, 0, 0 },
new float[] { -.0722f, -.0722f, -.0722f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 1, 1, 1, 0, 1 }
});
然后设置属性:
[GMapControl].ColorMatrix = matrixGrayInverted;
有关这些矩阵的用法,请参阅以下问题中的注释:
How can I gray-out a disabled PictureBox used as Button?
How to use a slider control to adjust the brightness of a Bitmap?
How to apply a fade transition effect to Images using a Timer?
Replacing colour of an Image