Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Asker

Pixel Data (Again)

This topic is 6089 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

I''m trying to load the pixel data from a 4-bit picture and I have loaded the first byte into a "char" and then I use this code the get the first and second pixel. int low = (color1 && 0x0f); int high = (color1 >> 4); but I doesn''t get the second pixel right it always comes out as a 1. what is wrong (except for my programming skill)

Share this post


Link to post
Share on other sites
Advertisement
I see two types of error you get:

1)
int low = (color1 & 0x0f);
int high = (color1 >> 4);

use just ONE &.........

2)
try to get it from a "unsigned char" not a "char" otherwise the "high" can get 0xfffffffX insted of 0x0000000X ( X being the number you want)

Share this post


Link to post
Share on other sites
    

unsigned char in;

unsigned char first = ( in >> 4 );
unsigned char second = ( in & 0x0F );



&& is the logical AND
& is the bitwise AND

Edited by - Fruny on November 19, 2001 3:28:57 AM

Share this post


Link to post
Share on other sites

  • 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!