如何解决将颜色图应用于SKBitmap
我想将颜色图应用于我的SKBitmap。我认为,将SKColorFilter与CreateTable()函数一起使用是实现这一目标的最佳方法。但是我的ApplyColormap()函数为我提供了完全纯色的位图,而不是给参数位图着色。
我使用library来获取颜色图的颜色值。
public static SKBitmap ApplyColormap(SKBitmap _bmp,Colormap _colormap)
{
byte[] atable = new byte[256];
byte[] rtable = new byte[256];
byte[] gtable = new byte[256];
byte[] btable = new byte[256];
// get colormap colors
ColorMap colorMap = new ColorMap(_colormap);
var mapColors = colorMap.Colors().ToList();
// define ARGB tables
for (int i = 0; i < 256; i++)
{
atable[i] = (byte)255;
rtable[i] = mapColors[i][0];
gtable[i] = mapColors[i][1];
btable[i] = mapColors[i][2];
}
SKBitmap colorBitmap = new SKBitmap(_bmp.Width,_bmp.Height);
SKCanvas sKCanvas = new SKCanvas(colorBitmap);
SKPaint paint = new SKPaint();
paint.ColorFilter = SKColorFilter.CreateTable(atable,rtable,gtable,btable);
sKCanvas.DrawBitmap(colorBitmap,paint: paint);
return colorBitmap;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。