开发时遇到的问题,设置图层样式时颜色的返回值是uint,一时不知改怎么转换为C#常用的RGB值了。

一番百度,结果如下:

RGB = R + G * 256 + B * 256 * 256

因此可得到如下反推代码:

        private Color To_RGB(int color)
{
int b = color / ( * );
int g = (color - b * * ) / ;
int r = color - b * * - g * ;
return Color.FromArgb(r, g, b);
}

网上还有位运算的快速算法:

        private uint To_uint(Color color)
{
return (uint)(((uint)color.B << ) | (ushort)(((ushort)color.G << ) | color.R));
}
private Color To_RGB(int color)
{
int r = 0xFF & color;
int g = 0xFF00 & color;
g >>= ;
int b = 0xFF0000 & color;
b >>= ;
return Color.FromArgb(r, g, b);
}

并看不懂,但是能用。

RGB与INT类型的转换的更多相关文章

  1. 【转】java中byte数组与int类型的转换(两种方式)----不错

    原文网址:http://blog.csdn.net/piaojun_pj/article/details/5903009 java中byte数组与int类型的转换,在网络编程中这个算法是最基本的算法, ...

  2. 总结:String类型与Int类型的转换【实现插入操作主键自增】

    1.String类型(此类型是数字格式的字符串类型)转换成Int类型 String str = "10000"; 转换成Int类型: int num = Integer.parse ...

  3. mysql 查询 int类型日期转换成datetime类型

    数据库日期类型是int类型的,该查询结果是datetime类型的 SELECT from_unixtime( `时间列名` ) FROM 表名 如果原来类型是datetime类型,查询结果要是int类 ...

  4. c#中RGB与int类型之间的转换

    Color color = Color.FromArgb(0, 0, 255);int colorInt = ParseRGB(color); --------------------- int Pa ...

  5. String与Int类型的转换

    http://blog.sina.com.cn/s/blog_4f9d6b1001000bfo.html int -> String int i=12345; String s="&q ...

  6. double与int类型自动转换

    package com.abc.test; public class SumTest { public static void main(String[] args) { //题目A:2+4+6+8+ ...

  7. long类型与int类型的转换

    在数据库中会出现,numberic转换为int出错 在网站中,提交form的时候出现long转int失败会报错,跌了两次坑,还有ajax提交的时候long转int会报错.

  8. java中byte数组与int类型的转换(两种方式)

    http://blog.csdn.net/z69183787/article/details/38564219 http://blog.csdn.net/z69183787/article/detai ...

  9. 03.枚举和string以及int类型之间的转换

    练习1:   将枚举类型强转成int类型 namespace _04.枚举类型的练习01 { //声明一个QQState类型的枚举 public enum QQState { OnLine, OffL ...

随机推荐

  1. maven web不能创建src/main/java等文件等问题

    我们在创建maven web项目的时候,默认只有src/main/resources这个source folder,我们按照maven结构添加src/main/java和src/test/java等s ...

  2. 前端JS批量添加校验数据唯一性

    <script type="text/javascript"> //维护删除数组中的某一项 Array.prototype.remove = function(val) ...

  3. open/read/write/close

    open 函数 函数原型 #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int o ...

  4. P4859 已经没有什么好害怕的了

    传送门 见计数想容斥 首先题目可以简单转化一下, 求 糖果比药片能量大的组数比药片比糖果能量大的组数多 $k$ 组 的方案数 因为所有能量各不相同,所以就相当于求 糖果比药片能量大的组数为 $(n+k ...

  5. HttpURLConnection发送GET、POST请求

    HttpURLConnection发送GET.POST请求 /** * GET请求 * * @param requestUrl 请求地址 * @return */ public String get( ...

  6. 全网最全的Windows下Anaconda2 / Anaconda3里正确下载安装Theano(图文详解)

    不多说,直接上干货! Theano的安装教程目前网上一搜很多,前几天折腾了好久,终于安装成功了Anaconda3(Python3)的Theano,嗯~发博客总结并分享下经验教训吧. 渣电脑,显卡用的是 ...

  7. 解决securecrt连接centos使用VIM编辑中文时乱码

    vim ~/.vimrc 添加两行 set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936

  8. JavaScript数据结构-12.散列碰撞(线性探测法)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. 基础js--调试js

    1,逻辑错误 常见错误: 是否由于拼写错误而导致申明了新的变量? 是否在条件判定上出现了疏漏? 方法:使用开发者工具调试代码 2,代码错误 常见错误: 是否拼写错误? 是否使用中文的符号? 扩展: 1 ...

  10. 使用go实现的lisp

    去年10月份的时候,就有这个打算了. 也是在上个月左右,抽空弄出来了个go语言实现的lisp. 当然,不能和common lisp比,函数的数量是远远不如的,也不能自己定义类型/类,同时宏系统也非常简 ...