[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

convert bitmap color to symbols

HELP ME!!!! I need a C++ source code on converting the bitmap color(RGB value) to symbols when it printed out later.
0
nurul_julia
Asked:
nurul_julia
1 Solution
 
scrapdogCommented:
You could do something like this:

char hex[] = "01234567ABCDEF";
  switch(colornum)
  {
  case 0:                  color="Black";
                                    break;
  case 128:                color="Maroon";
                                    break;
  case 32768:            color="Green";
                                    break;
  case 32896:            color="Olive Green";
                                    break;
  case 8388608:          color="Navy Blue";
                                    break;
  case 8388736:      color="Purple";
                                    break;
  case 8421376:      color="Teal";
                                    break;
  case 8421504:    color="Gray";
                                    break;
  case 12632256:      color="Silver";
                                    break;
  case 255:                  color="Red";
                                    break;
  case 65280:            color="Lime Green";
                                    break;
  case 16711680:   color="Blue";
                                    break;
  case 16711935:   color="Fuchsia";
                                    break;
  case 16776960:   color="Aqua";
                                    break;
  case 16777215:   color="White";
                                    break;
  default:
        color[0]='$';
        int h=colornum;
        for (i=7; i>=0; i--)
          color[i]=hex[(h>>=4)&15];
        color[9]=0;
  }


where colornum is an integer value contain the RGB color,
and color is a string.

If the color is not in the list, it is converted to a hex string.
0
 
pauloserraCommented:
If you have the RGB values in 32-bit format (it depends on the format of the bitmap, which may be device specific), you can use the macros:
GetBValue(color)
GetGValue(color)
GetRValue(color)
to get the Blue, Green and Red values and format them according to your convenience.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now