Solved

565

Posted on 2000-05-02
5
266 Views
Last Modified: 2008-03-03
I've got these 2 defines

This is the one I usually used, but the problem is that the r and g will only go till 127 and b till 255
#define RGB16(r,g,b) (unsigned short)( ((r >> 3) << 11) | ((g >> 2) << 5)  | (b >> 3) );

I changed a few things and now I've got the following, which works just perfect.

#define RGB16(r,g,b) (unsigned short)( ((r >> 3) << 10) | ((g >> 3) << 5)  | (b >> 3) );

I only want to verify that the second really is good for a 565 videocard.

What do you guys experts say?

0
Comment
Question by:CJ_S
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
nils pipenbrinck earned 15 total points
Comment Utility
The first macro is for 565 highcolor, the second one is for 1555 highcolor format.

Booth color formats are common in highcolor modes, and it depends on the video card you're using..

You should get the color format from the library you're using to get into graphic mode (or from the os if you're using win32 or ddraw or something like that).

Btw. When I'm doing graphics I usually do all my stuff in 565 and when I'm copying the screen to the video memory I convert to 1555 on the fly if nessesary. Doing the conversion is almost as fast as copying..


Nils
0
 
LVL 22

Author Comment

by:CJ_S
Comment Utility
I've got a 565 videocard, and the second one gives me a better scene...when I' using my real 1555 define, it'd look different on my machine, so I don't think that the second one is a 555 define....
and besides that, I know the colorformat the user has, either 565 or 555. That has already been taken care of.
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
Comment Utility
the second define is for 555 I can prove this:

when you use your rgb vaules you pass 8 bits into your macro.. Then you shift each component right by three bits. this gives you effectively 5 bits of color resolution (for each component of cause).

You're using 555 rgb format, not 565.

You can easy check the format. Please fill the screen with 0x7fff. If the screen will get white it's 555 (because you set all but the most significant bit (which is unused in 555 format)). If the screen will be cyan you're running in 565 format (since the most significant bit of red is missing, and that gives the bright cyan color).

Nils

0
 
LVL 22

Author Comment

by:CJ_S
Comment Utility
Very much true...I made the program check first whether the videocard was 565 or 555, mine came out as 565 (as usual) and the second define works like normal for me.
0
 
LVL 22

Author Comment

by:CJ_S
Comment Utility
Adjusted points from 10 to 15
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now