Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Help! Need to make my own color...

Reply
Thread Tools

Help! Need to make my own color...

 
 
arun
Guest
Posts: n/a
 
      01-27-2006
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.

 
Reply With Quote
 
 
 
 
pemo
Guest
Posts: n/a
 
      01-27-2006
arun wrote:
> 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?

--
==============
*Not a pedant*
==============


 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      01-27-2006
"arun" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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


 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      01-27-2006

"arun" <(E-Mail Removed)> wrote
>
>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).


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      01-27-2006
Malcolm said:

> An image is basically this
>
> struct colour
> {
> unsigned char red;
> unsigned char green;
> unsigned char blue;
> };


Wot, no alpha channel?!?



--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      01-28-2006

"Richard Heathfield" <(E-Mail Removed)> wrote
>> struct colour
>> {
>> unsigned char red;
>> unsigned char green;
>> unsigned char blue;
>> };

>
> 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.


 
Reply With Quote
 
RSoIsCaIrLiIoA
Guest
Posts: n/a
 
      01-31-2006
On Fri, 27 Jan 2006 21:13:12 +0000 (UTC), "Malcolm"
<(E-Mail Removed)> wrote:
>"arun" <(E-Mail Removed)> wrote
>>
>>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;
>}


why not this?

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

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


 
Reply With Quote
 
Vladimir S. Oka
Guest
Posts: n/a
 
      01-31-2006
RSoIsCaIrLiIoA wrote:
> On Fri, 27 Jan 2006 21:13:12 +0000 (UTC), "Malcolm"
> <(E-Mail Removed)> wrote:
> >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

 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      01-31-2006

"Vladimir S. Oka" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> RSoIsCaIrLiIoA wrote:
> > On Fri, 27 Jan 2006 21:13:12 +0000 (UTC), "Malcolm"
> > <(E-Mail Removed)> wrote:
> > >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.





 
Reply With Quote
 
Vladimir S. Oka
Guest
Posts: n/a
 
      01-31-2006
Barry wrote:
> "Vladimir S. Oka" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > RSoIsCaIrLiIoA wrote:
> > > On Fri, 27 Jan 2006 21:13:12 +0000 (UTC), "Malcolm"
> > > <(E-Mail Removed)> wrote:
> > > >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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using own classloader inside J2EE to load and unload own classes. Stefan Siegl Java 1 07-02-2013 05:05 AM
Allowing access to my own computers within my own network =?Utf-8?B?VHJldm9y?= Wireless Networking 2 07-20-2006 09:05 PM
I have built my own (simple) thread manager [TM], but just found java 5 has its own. Saverio M. Java 0 07-03-2006 08:52 AM
Your own photos in your own book Frank ess Digital Photography 1 12-09-2004 05:54 PM
Spam: Re: Own Your Own On-Line Travel Agency Howard NZ Computing 0 08-01-2003 07:46 AM



Advertisments