Jump to content
  • Advertisement

Archived

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

Etus

Finding the RGB values in a bitmap at a specific point

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

Hi, While programming my skydome using a gradient map, I decided to switch to vertex colors. The vertex colors are taken from the gradient map itself. To do that, I need to know how I can find the RGB values in a bitmap at a specific points(a vertex texture coords, for example). I tried several methods, but none worked. The bitmap data is stored as a 1D array. How can I do that? Thanks, Yuval [edited by - Etus on May 4, 2003 3:14:39 PM]

Share this post


Link to post
Share on other sites
Advertisement

for coords x and y in the texture

if the texture is tex[size], where size = width * height * 3

tex[x][y][0] = tex[(y * texWidth + x) * 3] ( *3 because RGB is 3 bytes)


Share this post


Link to post
Share on other sites
Thanks a lot - I forgot to multiply it in 3

I now have another problem:
When I access an array, I must use an integer(I can't write "terrainVertices[0.5f]" but "terrainVertices[1]"). When I access the bitmap rgb values using a vertex texture coords, I must turn these texture coords into an integer - thus, I miss the "fine tuning" float gives me with textures coords. What happens is that there's a fast switch between 1, to 2, to 3, etc. then using float(1.0f, 1.1f, 1.2f, ...).

Here's my code:


    
CVector3 SkyDome :: GetRGB(CVector2 uvCoord) {


uvCoord.x *= gradientMap->sizeX;
uvCoord.y *= gradientMap->sizeY;


int x = (int)uvCoord.x % gradientMap->sizeX;
int y = (int)uvCoord.y % gradientMap->sizeY;


CVector3 rgbColor;


rgbColor.x = (float)(gradientMap->data[(x + (y * gradientMap->sizeX) * 3)]);
rgbColor.y = (float)(gradientMap->data[(x + (y * gradientMap->sizeX) * 3) + 1]);
rgbColor.z = (float)(gradientMap->data[(x + (y * gradientMap->sizeX) * 3) + 2]);


rgbColor = Normalize(rgbColor);


return rgbColor;


}


What can I do to fix that problem?
And please, forgive my poor English.

- Yuval

[edited by - Etus on May 4, 2003 4:20:32 PM]

[edited by - Etus on May 4, 2003 4:21:05 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!