将颜色转换为字节值 [英] Convert color to byte value

查看:232
本文介绍了将颜色转换为字节值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,如何将 Color 对象转换为字节值?

In C#, how can I convert a Color object into a byte value?

例如,颜色 #FFF 将被转换为值 255

For example, the color #FFF would be converted to the value 255.

推荐答案

您可以获取.NET Color 对象的字节值与:

You can get the byte values of a .NET Color object with:

byte red = color.R;
byte green = color.G;
byte blue = color.B;

给你3个字节。我不知道你期望得到一个字节值。颜色(AFAIK)几乎从不表示单个字节。

That gives you 3 bytes. I don't know how you expect to get a single byte value. Colors are (AFAIK) almost never represented by single bytes.

这篇关于将颜色转换为字节值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆