Solved

565

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 clear a vector as well as how to detect empty vectors in C++.

770 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