[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

convert bitmap color to symbols

Posted on 1998-10-06
2
Medium Priority
?
370 Views
Last Modified: 2010-05-18
HELP ME!!!! I need a C++ source code on converting the bitmap color(RGB value) to symbols when it printed out later.
0
Comment
Question by:nurul_julia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
scrapdog earned 200 total points
ID: 1174607
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
 
LVL 1

Expert Comment

by:pauloserra
ID: 1174608
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question