Jump to content
  • Advertisement
Sign in to follow this  
Alessandro

Texture resampling

This topic is 4617 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'd like to resample a 1024x1024 texture to a 128x128 one using linear or bilinear interpolation. Any suggestion on how to do it ? Thanks

Share this post


Link to post
Share on other sites
Advertisement
I don't have any experience with this--but here's an idea. For each pixel in your destination image, you have 8*8 pixels in the source image. You should average the color values of these 64 pixels to get the color value of the destination pixel.

So you'd loop through the pixels like this (for the first row):

unsigned char outcolor[3];

for (int i = 0; i < width; i += 8)
{
for (int j = 0; j < 8; j++)
{
// get color values for the [i+j]th pixel and add to output color
}
}

// divide values in output color by 64.


I don't know, but maybe this is what is linear interpolation. [smile] A google should yield results though, or as a final resort, check the gimp source for scaling images.

/edit: fixed the increment in the inner loop

[Edited by - deavik on November 26, 2005 2:44:44 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!