.vssettings 文件(Visual Studio 设置)颜色格式
我正在基于 Visual Studio 主题为 Sublime text 创建自己的配色方案。
Visual Studio 主题已定义前景和背景,但它们不在标准 RGB 三元组中。我不知道这个数字意味着什么,我想知道如何将其转换为 RGB 三元组(即#FFFFFF)以在 Sublime Text 中使用。
示例:
<Item Name="Comment" Foreground="0x007B7466" Background="0x02000000" BoldFont="No"/>
<Item Name="Plain Text" Foreground="0x00F3F2F1" Background="0x002A2822" BoldFont="No"/>
<Item Name="Selected Text" Foreground="0x00FFFFFF" Background="0x0064614F" BoldFont="No"/>
我尝试在此处和谷歌上进行搜索,但显然我无法正确获取搜索词以找到正确的答案。
I'm creating my own color scheme for Sublime text based off of a Visual Studio Theme.
The Visual Studio theme has foreground and background defined, but they are not in the standard RGB triplet. I don't know what this number means, and I was wondering how I could convert it into a RGB triplet (ie #FFFFFF) for use in Sublime Text.
Sample:
<Item Name="Comment" Foreground="0x007B7466" Background="0x02000000" BoldFont="No"/>
<Item Name="Plain Text" Foreground="0x00F3F2F1" Background="0x002A2822" BoldFont="No"/>
<Item Name="Selected Text" Foreground="0x00FFFFFF" Background="0x0064614F" BoldFont="No"/>
I've tried searching on here and google, but apparently I can't get my search terms correct to find the right answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅供参考,vsettings 文件使用 BGR 而不是 RGB
Just as an FYI the vsettings file uses BGR not RGB
乍一看(并且了解 MS 如何处理颜色),这些似乎是十六进制形式的 ARGB 或 XRGB DWORD。不过,根据您正在做什么,它们可能是 A/XBGR。
最有可能的是,前两个字符是 Alpha,然后是红色、绿色和蓝色。这是一种非常标准的颜色布局方式,因为它完全适合内存寄存器并匹配几种格式的纹理数据。
然而,有些地方喜欢反转它,以匹配其他纹理格式。 A/X 保持在开头,然后是蓝色、绿色和红色。
通过提供 0x00FF0000,这应该很容易测试。如果是蓝色,则为 BGR;如果为红色,则为 RGB。
他们可能会使用第一个通道/字节作为 alpha 以外的其他东西。将数据打包到 3 通道纹理的 Alpha 通道中并不罕见。然而,只有一种颜色是 0x02...,其余的都是 0x00...,所以我不会发生这种情况(其中还有一个 3.5 字节的颜色,所以可能是拼写错误)。
您不需要对它们进行任何转换,因为它们已经是十六进制(实际代码十六进制,而不是
#...
Web 内容)。要“转换”网络十六进制三元组,只需删除 # 并在前面加上0x00
就可以了。所有其他字符保持不变(大小写不重要,尽管有些人喜欢大写作为过程)。These appear, at a glance (and with some knowledge of how MS likes to handle colors) to be ARGB or XRGB DWORDs in hex form. Depending on what you're doing, though, they could be A/XBGR.
Most likely, the first two characters are alpha, then red, green, and blue. That's a pretty standard way of laying out colors, since it neatly fits in a memory register and matches texture data for a few formats.
However, some places like to reverse that, which matches other texture formats. The A/X remains at the start, then blue, green, and red.
This should be easy to test for, by providing 0x00FF0000. If blue, the BGR, if red, RGB.
It is possible that they might be using the first channel/byte as something other than alpha. Packing data into the alpha channel of a 3-channel texture is not uncommon. However, only one of the colors is 0x02..., the rest are all 0x00..., so I wouldn't this is going on (there's also a 3.5 byte color in there, so perhaps typos).
You don't need to do any conversion with these, as they are already hex (actual code hex, not the
#...
web stuff). To "convert" a web hex triplet, just remove the # and prepend0x00
and you should be good. All the other characters remain the same (case shouldn't matter, though some people like uppercase as procedure).如果有人需要解析 VSSettings 颜色,您可以使用此代码(使用新的 Span API):
如果您无权访问
AsSpan()
,您可以更改Slice
对Substring
的操作。If anyone needs to parse VSSettings colors, you can use this code (using the new Span APIs):
If you don't have access to
AsSpan()
you can change theSlice
operations toSubstring
.