Solved

565

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

690 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