Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: algorithm of stretching (with linear interpolation) in 2D

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2003
    Posts
    15

    algorithm of stretching (with linear interpolation) in 2D

    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 ??
    thinkx

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: algorithm of stretching (with linear interpolation) in 2D

    linear interpolation :

    Code :
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •