Advertisement

reading specific pixels from a bitmap

Started by January 01, 2002 03:24 AM
3 comments, last by glGreenhorn 23 years, 1 month ago
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
If you use screen coordinates, then you can use GetPixel.
Advertisement
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
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
http://www.lectersoft.com
Yes, you can use GetPixel on any hdc. Just create a storage for a bitmap image and place the collision map into it.

This topic is closed to new replies.

Advertisement