unsigned int颜色存储格式:0xaabbggrr,其中a,b,g,r分别表示,透明度、蓝色、绿色、红色。

方法一:使用windows宏

unsigned int clr = 0x00FF0000;

char red = GetRValue(clr);

char green = GetGValue(clr);

char blue = GetBValue(clr);

方法二:使用移位操作

unsigned int clr = 0x00FF0000;

char red = clr & 0xFF;

char green = clr >> 8 & 0xFF;

char blue = clr >> 16 & 0xFF;

unsigned int 转 RGB的更多相关文章

  1. 深度解析C语言int与unsigned int

    就如同int a:一样,int 也能被其它的修饰符修饰.除void类型外,基本数据类型之前都可以加各种类型修饰符,类型修饰符有如下四种:1.signed----有符号,可修饰char.int.Int是 ...

  2. 坑!坑!坑!防不胜防的unsigned int的运算

    我很早之前就知道,unsigned int与int运算的时候,int会被转化为unsigned int来进行运算.一直觉得定这条规则的人是极度反人类的,虽说unsigned int可以表示更大的正值, ...

  3. Ubuntu gcc编译报错:format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=]

    平时用的都是Centos系统,今天偶然在Ubuntu下编译了一次代码,发现报错了: 源码: #include <stdio.h> #include <sys/time.h> # ...

  4. str转unsigned int

    用法 1 参数:参数类型为char, 十六进制字符串形式:0X××××××[NUT],十进制字符串形式:×××××××[NUT],字符串的最大长度为16,字符串结尾符必须为ascii码值0(NUT). ...

  5. 数32位 unsigned int中1的个数

    参考文章:http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html 最简单的方法: int BitCount0(unsigned ...

  6. for( unsigned int i=heapSize/2-1; i>=0; --i)

    unsigned int的表示 今天在写堆排序的时候遇到一个BUG void builMaxHeap( int *arr,unsigned int heapSize){ unsigned int i; ...

  7. C语言之强制类型转换与指针--#define DIR *((volatile unsigned int *) 0x0022)

    强制类型转换形式:(类型说明符) (表达式) 举例说明:1) int a; a = (int)1.9; 2)char *b; int *p; p = (int *) b; //将b的值强制转换为指向整 ...

  8. 嵌入式中的 *(volatile unsigned int *)0x500 解释

    C语言中*(volatile unsigned int *)0x500的解释: 如下: (unsigned int *)0x500:将地址0x500强制转化为int型指针*(unsigned int ...

  9. 对unsigned int和int进行移位操作的区别

    1. 无符号整数 unsigned int 对unsigned int进行移位操作时,最高位不会有任何特殊性. 无符号整数必须使用%u来打印 #include <stdio.h> int ...

随机推荐

  1. light oj 1153 - Internet Bandwidth【网络流无向图】

    1153 - Internet Bandwidth   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  2. CopyU!v2.2 增加对设备信息的识别

    更新版本的CopyU!v2.2已经完成大部分功能的设计,主打升级功能“设备信息识别”已经基本完成,现在放上测试截图:

  3. sql转Linq的工具

    本文转载:http://www.cnblogs.com/huangxincheng/archive/2011/05/12/2044990.html 介绍一个小工具 Linqer   这些天写Linq挺 ...

  4. ThinkPHP3.1新特性: 多层MVC支持

    ThinkPHP基于MVC(Model-View-Controller,模型-视图-控制器)模式,不过均支持多层(multi-Layer)设计. 模型(Model)层:默认的模型层由Model类构成, ...

  5. Android开发_Gson解析

    //转换器 GsonBuilder builder = new GsonBuilder(); // 不转换没有 @Expose 注解的字段 builder.excludeFieldsWithoutEx ...

  6. 【代码优化】坚持使用Override注解

    对于传统程序猿,注解里面最重要的就是Override注解了.这里的注解,都是指仅仅能用在方法中的声明, 她表示被注解的方法用于覆盖了父类的一个声明,假设坚持使用这个注解,能够防止一大类的非法错误. & ...

  7. MYSQLD c++函数修饰名转换工具c++filt

    会话1: mysql> select now(); 会话2: [root@localhost ~]# stap -v -e 'probe process("/usr/local/mys ...

  8. wireshark抓包图解 TCP三次握手/四次挥手详解

    http://www.seanyxie.com/wireshark%E6%8A%93%E5%8C%85%E5%9B%BE%E8%A7%A3-tcp%E4%B8%89%E6%AC%A1%E6%8F%A1 ...

  9. linux http请求监控工具httpry---官方文档

    原文地址:http://dumpsterventures.com/jason/httpry/ core program httpry is a specialized packet sniffer d ...

  10. find——文件查找命令 linux一些常用命令

    find 命令eg: 一般文件查找方法: 1.  find /home -name file  ,  在/home目录下查找文件名为file的文件2.  find /home -name '*file ...