Sign in to follow this  
_dogo

image

Recommended Posts

Hi. I have to process and modify an image in c/c++. ive done this before, but only with Cg, with shaders, and now i dont surely know how can is do this in c/c++. Could anyone help me with a simple example? it would be important... for example: how can i read and modify the pixel (x,y). thx

Share this post


Link to post
Share on other sites
Go over to NeHe and check out his tutorials. Pretty early on he starts playing around with textures and loading BMP images (Tutorial 6 I think). The image pixel data is basically stored in an array. Most times this is a simply width*height*(bitsperpixel/8) sized array. You store one byte for each red, green, blue value - hence the bitsperpixel/8 part. The first pixel would be the first three cells of the array, and the second pixel would be the 4th, 5th, and 6th pixel, and so on You should be able to pick this up pretty quickly if you have programmed before.

The CPU reference above means that once you have your image in memory (the array) you make some OpenGL calls to create a texture unit and bind the image data to the texture unit. This also loads the image data to video memory. You can at that point get rid of the image data in memory, since it's in the graphics card memory. In your case you wouldn't get rid of the data, since you want to access and modify it. Once modified you need to make another OpenGL call to re-load the image data back to video memory for that texture object.

hth
F451

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this