Scintillia 标记背景的颜色与预期不同
我正在尝试为我正在编写的记事本++插件设置Markerbackgrounds,以便可以突出显示某些行。颜色存储为从 Color.ToArgb() 转换而来的整数:
int colour = Convert.ToInt32(Color.LightSkyBlue.ToArgb())
根据我对 Scintillia 文档的理解,它只接受 RGB 颜色,因此我使用以下函数去除颜色的 Alpha 部分。这确实设置了一种颜色,但我得到的是橙色而不是蓝色,而不是蓝色。这是设置标记背景颜色的正确方法吗?
private static void DefineColor(int type, int colour)
{
string hexValue = colour.ToString("X");
hexValue = hexValue.Remove(0, 2);
//hexValue = "0x" + hexValue
int decValue = Convert.ToInt32(ColorTranslator.FromHtml(hexValue));
//int decValue = int.Parse("FF", System.Globalization.NumberStyles.AllowHexSpecifier);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERDEFINE, type, (int)SciMsg.SC_MARK_BACKGROUND);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETBACK, type, decValue);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETFORE, type, 0);
}
I'm trying to set Markerbackgrounds for a notepad++ plugin I'm writting so certain lines can be highlighted. The colours are stored as ints which are converted from Color.ToArgb():
int colour = Convert.ToInt32(Color.LightSkyBlue.ToArgb())
From what I understand of the Scintillia documentation it only accepts RGB colours so I use the following function to strip out the Alpha part of the colour. This does set a colour but instead of blue I'm getting orange instead of blue. Is this the right way to set a marker background colour?
private static void DefineColor(int type, int colour)
{
string hexValue = colour.ToString("X");
hexValue = hexValue.Remove(0, 2);
//hexValue = "0x" + hexValue
int decValue = Convert.ToInt32(ColorTranslator.FromHtml(hexValue));
//int decValue = int.Parse("FF", System.Globalization.NumberStyles.AllowHexSpecifier);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERDEFINE, type, (int)SciMsg.SC_MARK_BACKGROUND);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETBACK, type, decValue);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETFORE, type, 0);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这会去掉任何 alpha 值:
这会将颜色转换为整数值:
两者一起:
但我不知道 Scintillia 是否使用相同的颜色表示。可以将值存储为 BGR 而不是 RGB 格式。
This strips off any alpha value:
This converts the color to a integer value:
Both together:
But I don't know, if Scintillia uses the same color representation. May it stores the value in BGR instead of RGB format.