Sign in to follow this  

Texture resampling

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

This topic is 4434 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this