?
Solved

convert bitmap color to symbols

Posted on 1998-10-06
2
Medium Priority
?
369 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

762 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