Scintillia标记背景出来一种不同于预期的颜色

时间:2011-12-15 17:27:23

标签: c# notepad++ scintilla

我正在尝试将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);
    }

1 个答案:

答案 0 :(得分:0)

这剥夺了任何alpha值:

var colorOnly = Color.FromArgb(c.R, c.G, c.B);

这会将颜色转换为整数值:

int i = c.ToArgb();

两者在一起:

int i = Color.FromArgb(c.R, c.G, c.B).ToArgb();

但我不知道,如果Scintillia使用相同的颜色表示。可以将值存储在BGR而不是RGB格式中。

int bgr = (c.B * 256 + c.G) * 256 + c.R;
相关问题