Help! Need to make my own color...

A

arun

I have 3 compilers at home: MSVC++, DEV-C++, and Turbo C++ 3.0.

I would like to know how to make a color of my choice by specifying RGB
values. Perhaps MSVC++, Dev- C++ have their own libraries to do so.
Well, I would like to hear of that...

I am also kind of a knowledge seeker. I would like to know how to
actually make programs to create a color of your choice by specifying
RGB values. I work a lot with turbo c++ graphics. If anyone here knows
how to help me, it would be great.
 
P

pemo

arun said:
I have 3 compilers at home: MSVC++, DEV-C++, and Turbo C++ 3.0.

I would like to know how to make a color of my choice by specifying
RGB values. Perhaps MSVC++, Dev- C++ have their own libraries to do
so. Well, I would like to hear of that...

I am also kind of a knowledge seeker. I would like to know how to
actually make programs to create a color of your choice by specifying
RGB values. I work a lot with turbo c++ graphics. If anyone here knows
how to help me, it would be great.

Colors!

Think you'd best ask on a newsgroup where you'll get an answer - presumably
one to do with Windows programming? microsoft.public.win32.programmer.gdi
perhaps?
 
M

Mike Wahler

arun said:
I have 3 compilers at home: MSVC++, DEV-C++, and Turbo C++ 3.0.

I would like to know how to make a color of my choice by specifying RGB
values.

The C language has no notion of 'color' or 'screen'
or any other particular hardware device.
Perhaps MSVC++, Dev- C++ have their own libraries to do so.

Of those three implementations, I'm only familiar with Microsoft
Visual C++. And yes, it does come with extensive libraries
for doing many platform-specific things, such as video graphics
with colors, fonts, etc.
Well, I would like to hear of that...

See your VC++ documentation. Look up 'RGB', 'color', etc.
Also don't forget MSDN (www.mdsn.microsoft.com), where virtually
all the documentation for developer products is available, also
with much more useful information (code samples), bug workarounds,
etc.
I am also kind of a knowledge seeker.

Great. So are you reading books?
I would like to know how to
actually make programs to create a color of your choice by specifying
RGB values.

Simply put, RTFM.
I work a lot with turbo c++ graphics. If anyone here knows
how to help me, it would be great.

See above.

-Mike
 
M

Malcolm

arun said:
I have 3 compilers at home: MSVC++, DEV-C++, and Turbo C++ 3.0.

I would like to know how to make a color of my choice by specifying RGB
values. Perhaps MSVC++, Dev- C++ have their own libraries to do so.
Well, I would like to hear of that...

I am also kind of a knowledge seeker. I would like to know how to
actually make programs to create a color of your choice by specifying
RGB values. I work a lot with turbo c++ graphics. If anyone here knows
how to help me, it would be great.
An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{
int width;
int height;
struct colour *pixels;
}

Now you can manipulate this data in a totally portable way. For instance you
could write a routine to turn a full-colour image to black and white, by
changing all the pixels to an average value of grey.

To view it, you need to save it in an image format. Look up wotsit .org for
your favourite image format. (Choose a simple one, not GIF or JPEG, for a
first attempt).
 
R

Richard Heathfield

Malcolm said:
An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

Wot, no alpha channel?!?

:)
 
M

Malcolm

Richard Heathfield said:
Wot, no alpha channel?!?

:)
Alpha means that you can access pixels on 32 bit boundaries, as well as use
transparency.
But I thought it might confuse the OP, who doesn't seem to be very clear on
RGB colour values.
 
R

RSoIsCaIrLiIoA

An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{
int width;
int height;
struct colour *pixels;
}

why not this?

struct color{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{struct color pixel[1024][768];};
 
V

Vladimir S. Oka

RSoIsCaIrLiIoA said:
An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{
int width;
int height;
struct colour *pixels;
}

why not this?

struct color{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{struct color pixel[1024][768];};

Because 1024x768 is not the only resolution allowed by laws of physics!

Malcolm's code would work on my digital watch with 53x231 screen, and
only 16K of RAM, yours probably wouldn't even link (at least not
without serious warnings).

Cheers

Vladimir
 
B

Barry

Vladimir S. Oka said:
RSoIsCaIrLiIoA said:
An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{
int width;
int height;
struct colour *pixels;
}

why not this?

struct color{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{struct color pixel[1024][768];};

Because 1024x768 is not the only resolution allowed by laws of physics!

Malcolm's code would work on my digital watch with 53x231 screen, and
only 16K of RAM, yours probably wouldn't even link (at least not
without serious warnings).

Cheers

Vladimir

But Malcolm's code may or may not work on MS Windows, depending on
how the graphics side is treated. Windows likes to use:

struct color {
BYTE blue;
BYTE green;
BYTE red;
};

Thus another reason why such discussions don't belong on clc.
 
V

Vladimir S. Oka

Barry said:
Vladimir S. Oka said:
RSoIsCaIrLiIoA said:
On Fri, 27 Jan 2006 21:13:12 +0000 (UTC), "Malcolm"
An image is basically this

struct colour
{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{
int width;
int height;
struct colour *pixels;
}

why not this?

struct color{
unsigned char red;
unsigned char green;
unsigned char blue;
};

struct image
{struct color pixel[1024][768];};

Because 1024x768 is not the only resolution allowed by laws of physics!

Malcolm's code would work on my digital watch with 53x231 screen, and
only 16K of RAM, yours probably wouldn't even link (at least not
without serious warnings).

Cheers

Vladimir

But Malcolm's code may or may not work on MS Windows, depending on
how the graphics side is treated.

And why wouldn't it? Malcom just stated that images, in principle, can
be represented as above, and in standard C. There was no discussion on
how such an image would be displayed (if at all). The method of
displaying could certainly include casting to system-defined types.

My comment was meant to highlight better portability of Malcolm's
example.

OP's question, whilst off topic, was about representing colors using
RGB values, not displaying them on any given device/system. Admittedly,
OP muddied the waters by listing a few specific implementations.

Pixels certainly can be represented as below as well, but /not/ in
standard C, so that'd be even more off-topic. ;-)
Windows likes to use:

struct color {
BYTE blue;
BYTE green;
BYTE red;
};

Thus another reason why such discussions don't belong on clc.

I do agree that the OP's original question was quite off topic.

Cheers

Vladimir
 
K

Keith Thompson

Vladimir S. Oka said:
Barry wrote: [snip]
Pixels certainly can be represented as below as well, but /not/ in
standard C, so that'd be even more off-topic. ;-)
Windows likes to use:

struct color {
BYTE blue;
BYTE green;
BYTE red;
};

There's nothing non-standard about that as long as BYTE is a typedef.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top