Solved

convert bitmap color to symbols

Posted on 1998-10-06
2
364 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
2 Comments
 
LVL 5

Accepted Solution

by:
scrapdog earned 100 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

831 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