Jump to content
  • Advertisement

Archived

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

microsoft63

Is there any fuciton to know this?

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

As my title, I want to know about a funtion to get my RGB number(0,0,0), of a location on a picture. If anyone knows, tell me, please.... Thanks everyone.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Tried GetRGB(image,x,y)?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Btw, no. You need to write it yourself, which is not as hard as it may sound. Just find the algorithm to query a pixel from the fetched data (remeber to take in account which image format you are using i.e. RGBA = 8 bits for each channel, in that order)

Share this post


Link to post
Share on other sites
What API are you using and what do you mean by a picture, is it a loaded bitmap, an image file on disk?

Share this post


Link to post
Share on other sites
inline void GetRGB16( unsigned short color, unsigned short &r, unsigned short &g, unsigned short &b )
{
unsigned short red_mask = 0xF800;
unsigned short green_mask = 0x7E0;
unsigned short blue_mask = 0x1F;

r = (color & red_mask) >> 11;
g = (color & green_mask) >> 5;
b = (color & blue_mask);

return;
}
inline void GetRGB24( unsigned long color, unsigned long &r, unsigned long &g, unsigned long &b )
{
unsigned long red_mask = 0xF800;
unsigned long green_mask = 0x7E0;
unsigned long blue_mask = 0x1F;

r = (color & red_mask) >> 16;
g = (color & green_mask) >> 8;
b = (color & blue_mask);

return;
}


Supposing you are not using Alpha values.

--
You're Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net's DirectX FAQ. (not as cool as the Graphics and Theory FAQ)


[edited by - Pipo DeClown on June 2, 2004 12:00:49 PM]

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!