C Language Color Conversion macros

Source: Internet
Author: User

C Language Color Conversion macros


#define COLOR_BPP16_RGB555/* Win RGB */#define COLOR_RGB (R,g,b) ((COLORREF) (((BYTE) (R) | ( (WORD) ((BYTE) (g)) <<8)) | (((DWORD) (BYTE) (b)) <<16)) #define COLOR_RGBA (R,g,b,a) ((COLORREF) (((DWORD) (BYTE) (a) <<24) | Color_rgb (R,G,B))/*/Win PALETTERGB */#define COLOR_PALRGB (r,g,b) (0x02000000 | Color_rgb (R,G,B)//Win Paletteindex */#define COLOR_PALINDEX (i) ((COLORREF) (0x01000000 | (DWORD) (WORD) (i))) /* Win Getrvalue */#define COLOR_GET_RED ((DWORD) (RGB) & 0xff)/*/Win Getgvalue */#define Color_get_g Reen (RGB) ((Byte) ((DWORD) (((WORD) (RGB)) >> 8) & 0xff)/*/Win Getbvalue */#define COLOR_GET_BLUE (RGB) ((Byte ) (((DWORD) ((RGB) >>16) & 0xff)) #define COLOR_GET_ALPHA (RGBA) ((BYTE) (((DWORD) ((RGBA) >>24) & 0XFF)/* * bits color <=> bits color */#define RGB888TORGB565 (R,G,B) ((Word) ((word) (r) <<8 &0xf800 )| ((((WORD) (g)) <<3) &0x7e0) | (((WORD) (b)) >>3)) #define RGBTORGB565 (RGB) ((Word) (((Word) ((RGB) >>3) & (0x1F)) <<11) | (((((&GT;&GT;10) (() ((RGB)) & (0x3F)) <<5) | (((WORD) ((RGB) >>19)) & (0x1F)))) #define RGB888TORGB555 (R,G,B) (Word) (((Word) (r) <<7) &0x7c00) | ( (((WORD) (g)) <<2) &0x3e0) | (((WORD) (b)) >>3)) #define RGBTORGB555 (RGB) (Word) ((((() (((>>3) (()) & (0x1F) <<10) | ( ((((WORD) (RGB) >>11) & (0x1F)) <<5) | (((WORD) ((RGB) >>19)) & (0x1F)))) #define RGB555TORGB (rgb555) ((DWORD) (((BYTE) (((rgb555) >>7) &0xf8) | ( (WORD) ((BYTE) ((((rgb555) >>2) &0xf8) <<8)) | (((DWORD) (BYTE) (((rgb555) <<3) &0xf8)))) #define RGB565TORGB (rgb565) ((DWORD) (((BYTE) (((rgb565) &0xf800) >>11) | ( (WORD) ((BYTE) ((((rgb565) &0x07e0) >>5) <<2))) | (((DWORD) (BYTE) (((rgb565) &0x001f) <<3)))) #ifdef color_bpp16_rgb555 #define BPP24TOBPP16 rgb888torgb555 #define BPP16TOBPP24 rgb555torgb#else #define BPP24TOBPP16 rgb888torgb565 #defINE BPP16TOBPP24 Rgb565torgb#endif 


C Language Color Conversion macros

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.