Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

565

Posted on 2000-05-02
5
Medium Priority
?
309 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
[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
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
nils pipenbrinck earned 45 total points
ID: 2773086
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
ID: 2773288
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
ID: 2773372
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
ID: 2773404
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
ID: 2773409
Adjusted points from 10 to 15
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 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…
Suggested Courses

609 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