Solved

565

Posted on 2000-05-02
5
276 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

914 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

12 Experts available now in Live!

Get 1:1 Help Now