Texture resampling

Started by
2 comments, last by Alessandro 18 years, 4 months ago
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
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]
How about gluScaleImage(). I've just started using it and it works ok.
Thanks for your answers, indeed gluScaleImage() was what i really needed !
Rating++ ...

This topic is closed to new replies.

Advertisement