Average Color of TIles
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?
Lock the last level of the texture, assuming you used full mipmaps, it will be the final 1x1 representation of the texture.
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.
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.
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]
--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]
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement