Archived

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

Average Color of TIles

This topic is 5111 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! I''m trying to programe a mini map, which shows a big map on a small texture, as you know in AoE eg. For that, I try to get the average Color of every TIle which is used in the big map. I lock the texture for that an try to get out all color components. I sum all components for every texture pixel. Then i divide them with the number of texture Pixels. It works, but the results are not very good... sometimes the colors dont seem to be like the original texture. For example a green Texture-Tile is on the minimap somethin glike darkpurple Is there another way to calculate the color?

Share this post


Link to post
Share on other sites
I was afraid you''d say that.

Are you sure you''re summing the values for each channel correctly? As unsigned, and into a type large enough (32 bit should be fine, 16 bit isn''t enough, and 8 bit certainly isn''t enough)?

Green grass going to dark purple would imply your green wrapped around back to near 0, or was though of as a negative value.

The average value should be fine in most tiles.

Share this post


Link to post
Share on other sites
For every tile in the map
--Scale tile to 1 pixel square
--Render tile

Depends on your tiles.. If they are square, this should work.
If you're doing 3D, ignore this post.

--
You're Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..

[edited by - Pipo DeClown on December 16, 2003 2:21:31 PM]

Share this post


Link to post
Share on other sites
The red, green, and blue values are packed into a single 32-byte value (with 8 bits extra padding/alpha). I suspect that you are adding these values. Rather you need to split up the 32-byte value (an unsigned long, right) into three different 8-bit components, and then add and average each of the components seperately . Then repack them.

Share this post


Link to post
Share on other sites