Jump to content
  • Advertisement
Sign in to follow this  
_nomad_

How to store 18bits?

This topic is 4808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Let's say a screen is 18bits per pixel. How do i store each pixel? An unsigned int is only 16bits, I still need two bits. I'm using c++. I think using a long (32 bits?) is too wasteful (espcially since I'm developping for mobile devices). Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I believe you wouldn't be directly accessing the bits of a display mode nor do I belive there is such a display mode as 18 bits. That would be just.....odd. I bet you that an API is used for that purpose.

In all the time I've been programming I have never seen nor hear of such a display mode of 18 bits. You have 8, 16, 24 or 32. I do not see at all why you would use 18 bits. Also, those sizes are that size ofr a reason. Unless you are writing your own driver for something then you are going to have to stick with what the device allows.

Alternatively, you could use a bit feild representing each pixel. Then you just use an array to represent your display. But then you are going to have to convert you pixel information to the pixel format of the display the device uses. But there is no such thing as an 18 bit data type unless you use a bit field.

Share this post


Link to post
Share on other sites
I'm afraid that your going to have to go with a 'long' storage class

The reason is: basically everything that has to do with data in computers follows the rule of the 2nd power (e.g. 2,4,8,16,34,1024x768, ect.)

Share this post


Link to post
Share on other sites
Quote:
Original post by sakky
I believe you wouldn't be directly accessing the bits of a display mode nor do I belive there is such a display mode as 18 bits. That would be just.....odd. I bet you that an API is used for that purpose.

In all the time I've been programming I have never seen nor hear of such a display mode of 18 bits. You have 8, 16, 24 or 32. I do not see at all why you would use 18 bits. Also, those sizes are that size ofr a reason. Unless you are writing your own driver for something then you are going to have to stick with what the device allows.

Alternatively, you could use a bit feild representing each pixel. Then you just use an array to represent your display. But then you are going to have to convert you pixel information to the pixel format of the display the device uses. But there is no such thing as an 18 bit data type unless you use a bit field.


Hello,

If there is no sch display as 18bits, then why can this phone: http://www.forum.nokia.com/main/0,,018-2355,00.html?model=6680 display it as such? (look at the Screen Display section in the middle left part of the page)

and further google turns results that verifies that the phone can display 262,144 colors. or am i understanding something wrong? :(

Share this post


Link to post
Share on other sites
Quote:
Original post by zealotgi
I'm afraid that your going to have to go with a 'long' storage class

The reason is: basically everything that has to do with data in computers follows the rule of the 2nd power (e.g. 2,4,8,16,34,1024x768, ect.)


hi,

ok. i guess i'll have to use 32bits then...:)

thanks.

Share this post


Link to post
Share on other sites
18bits sounded a little odd, so I went looking, and found this article, which suggests it really is as pointless as it sounds.

yckx

Share this post


Link to post
Share on other sites
If I remember correctly you can do something like this


unsigned int alittleshort : 18;





Don't quote me on that, but I believe it is something close to that. The catch is its still going to ultimately use 32-bits, the compiler just ought to limit you to using the first 18-bits.

[edit]
See down lower for correct code.

[Edited by - Rattrap on June 17, 2005 6:09:57 AM]

Share this post


Link to post
Share on other sites
The display being 18 bits doesn't normally mean the frame buffer will be 18 bits per pixel. LCDs (including cheaper PC monitors) can often only display an effective 18 bits as they are not physically capable of producing more than 64 shades for each colour (red, green and blue). The 18 bits refers to the number of different colours the screen can physically display, the frame buffer will usually be 16 bit, 24 bit or 32 bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by zealotgi
I'm afraid that your going to have to go with a 'long' storage class

The reason is: basically everything that has to do with data in computers follows the rule of the 2nd power (e.g. 2,4,8,16,34,1024x768, ect.)

That's usually true with modern computer architectures but there have been systems in the past with 6, 12, 18, 36 and 60 bit words. Also, it's 32 not 34 [smile]

Share this post


Link to post
Share on other sites
Exactly, I was about to suggest that perhaps a byte on that phone is 6 bits. That's 64 combinations. That's at least enough for uppercase and lowercase letters, and digits.

Or it could be that there are only 6*6*6 usable combinations out of a 24 or 32 bit value and the other combinations are meaningless.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!