Archived

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

glGreenhorn

reading specific pixels from a bitmap

Recommended Posts

hey can i somehow use glReadPixels() (or anything else) to get the color value of a specific pixel? i have a separate bitmap prepared for that - should i create a texture of it or can i access the bitmap directly? i know the pixel locarion. or better yet - is there a way to simply test if the pixels is of certain color, not get the color and test it myself? thanks, i''d appreciate anyone suggesting the fastest and simplest way to do that. keep cool

Share this post


Link to post
Share on other sites
i can''t use screen coordinates as the bitmap i''m trying to get the pixel info from is a monochrome collision map. i need to test if the user clicks on the "nonpassable" region of the texture tile. i don''t see any other way to do that than to use a collision map. so i still need to load it separately and access its pixels separately... how would i go about that???

umm... i''m not sure (haven''t tested it yet), but can''t GetPixel() access any bitmap loaded into a hdc, not necessarily from the screen? is GetPixel() the fastest way, however? doesn''t ogl provide somekind of a more lowlevel approach?

keep cool

Share this post


Link to post
Share on other sites
if you have a pointer to the image you can access it though some olgo. like this

color = image_pointer[y*screen_width+x]

thats the basic idea i dont know if you wanna read red,green,blue or a 16bit number but its a start and i dont know if i got it exactly right.



http://www.lectersoft.com

Share this post


Link to post
Share on other sites
Yes, you can use GetPixel on any hdc. Just create a storage for a bitmap image and place the collision map into it.

Share this post


Link to post
Share on other sites