View Full Version : algorithm of stretching (with linear interpolation) in 2D

05-24-2004, 11:26 PM
Hi guys,
I am looking for a stretching and linear interpolation algorithm on 2D images... because the interpolation of windows (depends on the device) and some times is very slow !!!

can anybody help me ??

05-25-2004, 10:47 AM
linear interpolation :

for each dst_pixel {
float src_pixel.x = dst_pixel.x / (float)ratio.x;
int p1x = (int) src_pixel.x; // should be a floor()
float coef = src_pixel.x - p1x;
color dst_color = (1-coef)*getColor(p1x) + coef*getColor(p1x+1);This is for 1d images, you should be a able to do the conversion to 2d. Not sure if it will be fast though.