Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Convert 8 bit values to 32 bit
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
crossley7




PostPosted: Mon May 02, 2011 8:17 pm   Post subject: Convert 8 bit values to 32 bit

I'm using Dev C++ with the G++ compiler. I am trying to create a program that reads in a bmp and converts the pixel colours to the opposite ie black becomes white.

code:

Uint8 r,g,b,a;
Uint32 pixel = get_pixel32( surface, x, y );
SDL_GetRGBA (pixel, surface->format, &r, &g, &b, &a);
r = (Uint8)255 - r;
g = (Uint8)255 - g;
b = (Uint8)255 - b;
a = (Uint8)255 - a;
pixel =(Uint8)r*1000000+(Uint8)b*10000+(Uint8)g*100+(Uint8)a;


I know that the last line is horribly wrong, but I have no idea as to what it should actually be.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon May 02, 2011 8:19 pm   Post subject: RE:Convert 8 bit values to 32 bit

You might be looking for http://en.wikipedia.org/wiki/Logical_shift
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Mon May 02, 2011 8:23 pm   Post subject: RE:Convert 8 bit values to 32 bit

Your probably looking for this too ;P http://en.wikipedia.org/wiki/List_of_Latin_phrases:_I#id_est
crossley7




PostPosted: Mon May 02, 2011 8:36 pm   Post subject: RE:Convert 8 bit values to 32 bit

Thanks, that is a lot of help, but I'm not sure how to implement it, but will keep working on it to see if i can figure it out
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: