![](smile.gif)
retriving pixel color
if i have a bmp that i load from file, how can i can get color value of the pixel at xth column and yth row?
thuned
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
![](smile.gif)
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
If you have it in a single buffer, you can use the formula:
colour = buffer[x + y * width of buffer];
width of buffer is usually the width of the bitmap, but to avoid alignment problems you should know the actual width of the buffer.
colour = buffer[x + y * width of buffer];
width of buffer is usually the width of the bitmap, but to avoid alignment problems you should know the actual width of the buffer.
i'm using nehe's bmp loading function
AUX_RGBImageRec *LoadBMP(char *Filename)
is that return type a "single buffer"?
so would something like that work?
and i know that some bmp has garbage on the ends of each line. does AUX_RGBImageRec take care of it or do i have to do it myself?
life is unfair, take advantage of it.
UNMB2 - if the link doesn't work, try clicking it![](smile.gif)
Edited by - thuned on February 8, 2001 12:21:45 AM
AUX_RGBImageRec *LoadBMP(char *Filename)
is that return type a "single buffer"?
AUX_RGBImageRec *TextureImage;BYTE* Image[height*width];Image[0] = (BYTE*)(TextureImage);
so would something like that work?
and i know that some bmp has garbage on the ends of each line. does AUX_RGBImageRec take care of it or do i have to do it myself?
life is unfair, take advantage of it.
UNMB2 - if the link doesn't work, try clicking it
![](smile.gif)
Edited by - thuned on February 8, 2001 12:21:45 AM
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
The definition of AUX_RGBImageRec is something like:
So something like:
BYTE Colour = TextureImage.data[XPos + YPos * TextureImage.sizeY];
should work![](smile.gif)
And you probably wont have to worry about the alignment, as I assume you're using images that are a power of 2. Didn't notice you posted in the NeHe forum or I would have told you this in the first place![](smile.gif)
Edited by - Quantum on February 8, 2001 12:41:05 AM
typedef struct _AUX_RGBImageRec{ unsigned char* data; GLint sizeX; GLint sizeY;}
So something like:
BYTE Colour = TextureImage.data[XPos + YPos * TextureImage.sizeY];
should work
![](smile.gif)
And you probably wont have to worry about the alignment, as I assume you're using images that are a power of 2. Didn't notice you posted in the NeHe forum or I would have told you this in the first place
![](smile.gif)
Edited by - Quantum on February 8, 2001 12:41:05 AM
got a problem:
i got layer declared as AUX_RGBImageRec layer[3];
and i loaded up the 0th element
works, i''m using nehe''s bitmap text btw
but when i do BYTE a = (BYTE)(layer[0].data[0]);
it crashes
y does it crash?
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
i got layer declared as AUX_RGBImageRec layer[3];
and i loaded up the 0th element
glPrint("Size: %2.0f, %2.0f", (float)layer[0].sizeX, (float)layer[0].sizeY);
works, i''m using nehe''s bitmap text btw
but when i do BYTE a = (BYTE)(layer[0].data[0]);
it crashes
y does it crash?
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
![](smile.gif)
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
nm, i got it working
just changed it to 3*(XPos + YPos * TextureImage.sizeX) and it worked![](smile.gif)
thanks
thuned
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
just changed it to 3*(XPos + YPos * TextureImage.sizeX) and it worked
![](smile.gif)
thanks
thuned
life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
![](smile.gif)
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement