Conversion of 8-bit color index to 24-bit color in DXF format

Source: Internet
Author: User

The current colors are basically 24 bits

Color, which consists of three RGB components, each of which occupies 8 bits. The final color is obtained through RGB mixture.

The 32-bit color is based on RGB and an alpha channel is introduced to describe the transparency of the color. The smaller the Alpha value, the higher the transparency.

The 8-digit color is 256 colors, which can represent 256 colors. There are currently two definitions. For details, see:Http://en.wikipedia.org/wiki/8_bit_color

One is to define 256 colors directly, and access these 256 colors through indexes; the other is based on the same RGB component, in the format: r g B.

Windows uses the first solution to describe the 8-bit color. We can use the following array to convert the DXF format on Windows from the 8-bit color to the 24-bit color.

// 256 color index value range: [0,255]

const static COLORREF CadColor[256] = {RGB(255,255,255),RGB(255,  0,  0), RGB(255,255,  0), RGB(  0,255,  0), RGB(  0,255,255), RGB(  0,  0,255),// 5RGB(255,  0,255), RGB(255,255,255), RGB(128,128,128), RGB(192,192,192), RGB(255,  0,  0),// 10RGB(255,127,127), RGB(204,  0,  0), RGB(204,102,102), RGB(153,  0,  0), RGB(153, 76, 76),// 15RGB(127,  0,  0), RGB(127, 63, 63), RGB( 76,  0,  0), RGB( 76, 38, 38), RGB(255, 63,  0),// 20RGB(255,159,127), RGB(204, 51,  0), RGB(204,127,102), RGB(153, 38,  0), RGB(153, 95, 76),// 25RGB(127, 31,  0), RGB(127, 79, 63), RGB( 76, 19,  0), RGB( 76, 47, 38), RGB(255,127,  0),// 30RGB(255,191,127), RGB(204,102,  0), RGB(204,153,102), RGB(153, 76,  0), RGB(153,114, 76),// 35RGB(127, 63,  0), RGB(127, 95, 63), RGB( 76, 38,  0), RGB( 76, 57, 38), RGB(255,191,  0),// 40RGB(255,223,127), RGB(204,153,  0), RGB(204,178,102), RGB(153,114,  0), RGB(153,133, 76),// 45RGB(127, 95,  0), RGB(127,111, 63), RGB( 76, 57,  0), RGB( 76, 66, 38), RGB(255,255,  0),// 50RGB(255,255,127), RGB(204,204,  0), RGB(204,204,102), RGB(153,153,  0), RGB(153,153, 76),// 55RGB(127,127,  0), RGB(127,127, 63), RGB( 76, 76,  0), RGB( 76, 76, 38), RGB(191,255,  0),// 60RGB(223,255,127), RGB(153,204,  0), RGB(178,204,102), RGB(114,153,  0), RGB(133,153, 76),// 65RGB( 95,127,  0), RGB(111,127, 63), RGB( 57, 76,  0), RGB( 66, 76, 38), RGB(127,255,  0),// 70RGB(191,255,127), RGB(102,204,  0), RGB(153,204,102), RGB( 76,153,  0), RGB(114,153, 76),// 75RGB( 63,127,  0), RGB( 95,127, 63), RGB( 38, 76,  0), RGB( 57, 76, 38), RGB( 63,255,  0),// 80RGB(159,255,127), RGB( 51,204,  0), RGB(127,204,102), RGB( 38,153,  0), RGB( 95,153, 76),// 85RGB( 31,127,  0), RGB( 79,127, 63), RGB( 19, 76,  0), RGB( 47, 76, 38), RGB(  0,255,  0),// 90RGB(127,255,127), RGB(  0,204,  0), RGB(102,204,102), RGB(  0,153,  0), RGB( 76,153, 76),// 95RGB(  0,127,  0), RGB( 63,127, 63), RGB(  0, 76,  0), RGB( 38, 76, 38), RGB(  0,255, 63),// 100RGB(127,255,129), RGB(  0,204, 51), RGB(102,204,127), RGB(  0,153, 38), RGB( 76,153, 95),// 105RGB(  0,127, 31), RGB( 63,127, 79), RGB(  0, 76, 19), RGB( 38, 76, 47), RGB(  0,255,127),// 110RGB(127,255,191), RGB(  0,204,102), RGB(102,204,153), RGB(  0,153, 76), RGB( 76,153,114),// 115RGB(  0,127, 63), RGB( 63,127, 95), RGB(  0, 76, 38), RGB( 38, 76, 57), RGB(  0,255,191),// 120RGB(127,255,223), RGB(  0,204,153), RGB(102,204,178), RGB(  0,153,114), RGB( 76,153,133),// 125RGB(  0,127, 95), RGB( 63,127,111), RGB(  0, 76, 57), RGB( 38, 76, 66), RGB(  0,255,255),// 130RGB(127,255,255), RGB(  0,204,204), RGB(102,204,204), RGB(  0,153,153), RGB( 76,153,153),// 135RGB(  0,127,127), RGB( 63,127,127), RGB(  0, 76, 76), RGB( 38, 76, 76), RGB(  0,191,255),// 140RGB(127,223,255), RGB(  0,153,204), RGB(102,178,204), RGB(  0,114,153), RGB( 76,133,153),// 145RGB(  0, 95,127), RGB( 63,111,127), RGB(  0, 57, 76), RGB( 38, 66, 76), RGB(  0,127,255),// 150RGB(127,191,255), RGB(  0,102,204), RGB(102,153,204), RGB(  0, 76,153), RGB( 76,114,153),// 155RGB(  0, 63,127), RGB( 63, 95,127), RGB(  0, 38, 76), RGB( 38, 57, 76), RGB(  0, 63,255),// 160RGB(127,159,255), RGB(  0, 51,204), RGB(102,127,204), RGB(  0, 38,153), RGB( 76, 95,153),// 165RGB(  0, 31,127), RGB( 63, 79,127), RGB(  0, 19, 76), RGB( 38, 47, 76), RGB(  0,  0,255),// 170RGB(127,127,255), RGB(  0,  0,204), RGB(102,102,204), RGB(  0,  0,153), RGB( 76, 76,153),// 175RGB(  0,  0,127), RGB( 63, 63,127), RGB(  0,  0, 76), RGB( 38, 38, 76), RGB( 63,  0,255),// 180RGB(159,127,255), RGB( 51,  0,204), RGB(127,102,204), RGB( 38,  0,153), RGB( 95, 76,153),// 185RGB( 31,  0,127), RGB( 79, 63,127), RGB( 19,  0, 76), RGB( 47, 38, 76), RGB(127,  0,255),// 190RGB(191,127,255), RGB(102,  0,204), RGB(153,102,204), RGB( 76,  0,153), RGB(114, 76,153),// 195RGB( 63,  0,127), RGB( 95, 63,127), RGB( 38,  0, 76), RGB( 57, 38, 76), RGB(191,  0,255),// 200RGB(223,127,255), RGB(153,  0,204), RGB(178,102,204), RGB(114,  0,153), RGB(133, 76,153),// 205RGB( 95,  0,127), RGB(111, 63,127), RGB( 57,  0, 76), RGB( 66, 38, 76), RGB(255,  0,255),// 210RGB(255,127,255), RGB(204,  0,204), RGB(204,102,204), RGB(153,  0,153), RGB(153, 76,153),// 215RGB(127,  0,127), RGB(127, 63,127), RGB( 76,  0, 76), RGB( 76, 38, 76), RGB(255,  0,191),// 220RGB(255,127,223), RGB(204,  0,153), RGB(204,102,178), RGB(153,  0,114), RGB(153, 76,133),// 225RGB(127,  0, 95), RGB(127, 63,111), RGB( 76,  0, 57), RGB( 76, 38, 66), RGB(255,  0,127),// 230RGB(255,127,191), RGB(204,  0,102), RGB(204,102,153), RGB(153,  0, 76), RGB(153, 76,114),// 235RGB(127,  0, 63), RGB(127, 63, 95), RGB( 76,  0, 38), RGB( 76, 38, 57), RGB(255,  0, 63),// 240RGB(255,127,159), RGB(204,  0, 51), RGB(204,102,127), RGB(153,  0, 38), RGB(153, 76, 95),// 245RGB(127,  0, 31), RGB(127, 63, 79), RGB( 76,  0, 19), RGB( 76, 38, 47), RGB( 51, 51, 51),// 250RGB( 91, 91, 91), RGB(132,132,132), RGB(173,173,173), RGB(214,214,214), RGB(255,255,255)// 255};

ACI-RGB table

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.