我正在使用C#和WinForms开发一个应用程序,带有GMap.NET库。有人知道如何设置Map的黑暗模式吗?我目前使用的OpenStreetMap:map.MapProvider = OpenStreetMapProvider.Instance我看过文档,但我没有找到任何东西。当使用谷歌Map时,可以在CSS中设置颜色参数,但我没有找到直接在C#中定义CSS或主题的方法。
map.MapProvider = OpenStreetMapProvider.Instance
slwdgvem1#
GMap.NET提供了三种预定义的渲染模式:
[GMapControl].NegativeMode
[GMapControl].GrayScaleMode
这些呈现模式使用ColorMatrix对象来定义每个通道的颜色量。它还提供了指定自定义ColorMatrix的方法,可设置[GMapControl].ColorMatrix属性。逆矩阵是这样的~:
[GMapControl].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 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 }});
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的颜色:
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 }});
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 },
型然后设定属性:
[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的
1条答案
按热度按时间slwdgvem1#
GMap.NET提供了三种预定义的渲染模式:
[GMapControl].NegativeMode
[GMapControl].GrayScaleMode
这些呈现模式使用ColorMatrix对象来定义每个通道的颜色量。
它还提供了指定自定义ColorMatrix的方法,可设置
[GMapControl].ColorMatrix
属性。逆矩阵是这样的~:
字符串
灰度矩阵如下所示(我的解释):
型
如果负片模式不完全是您要寻找的,您可以反转灰阶ColorMatrix的颜色:
型
然后设定属性:
型
关于这些矩阵的用法,请参阅以下问题中的注解:
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的