Changeset 3529


Ignore:
Timestamp:
05/27/09 07:04:30 (4 years ago)
Author:
sam
Message:

Fix img2twit's rendering. Apparently CGAL's Delaunay triangulation module
does not work with negative indices.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/examples/img2twit.cpp

    r3528 r3529  
    649649        float fx, fy, fr, fg, fb, fs; 
    650650        get_point(i, &fx, &fy, &fr, &fg, &fb, &fs); 
    651         dt.insert(K::Point_2(fx, fy)); 
     651        dt.insert(K::Point_2(fx + dw * RANGE_X, fy + dh * RANGE_Y)); 
    652652        /* Keep link to point */ 
    653653        lookup[(int)(fx * 2) + dw * RANGE_X * 2 * (int)(fy * 2)] = i; 
     
    655655 
    656656    /* Add fake points to close the triangulation */ 
    657     dt.insert(K::Point_2(-dw * RANGE_X, -dh * RANGE_Y)); 
    658     dt.insert(K::Point_2(2 * dw * RANGE_X, -dh * RANGE_Y)); 
    659     dt.insert(K::Point_2(-dw * RANGE_X, 2 * dh * RANGE_Y)); 
    660     dt.insert(K::Point_2(2 * dw * RANGE_X, 2 * dh * RANGE_Y)); 
     657    dt.insert(K::Point_2(0, 0)); 
     658    dt.insert(K::Point_2(3 * dw * RANGE_X, 0)); 
     659    dt.insert(K::Point_2(0, 3 * dh * RANGE_Y)); 
     660    dt.insert(K::Point_2(3 * dw * RANGE_X, 3 * dh * RANGE_Y)); 
    661661 
    662662    for(y = ry; y < ry + rh; y++) 
     
    664664        for(x = rx; x < rx + rw; x++) 
    665665        { 
    666             K::Point_2 m((float)x * dw * RANGE_X / p->w, 
    667                          (float)y * dh * RANGE_Y / p->h); 
     666            K::Point_2 m((float)x * dw * RANGE_X / p->w + dw * RANGE_X, 
     667                         (float)y * dh * RANGE_Y / p->h + dh * RANGE_Y); 
    668668            Point_coordinate_vector coords; 
    669669            CGAL::Triple< 
     
    680680                float fx, fy, fr, fg, fb, fs; 
    681681 
    682                 fx = (*it).first.x(); 
    683                 fy = (*it).first.y(); 
     682                fx = (*it).first.x() - dw * RANGE_X; 
     683                fy = (*it).first.y() - dh * RANGE_Y; 
    684684 
    685685                if(fx < 0 || fy < 0 
Note: See TracChangeset for help on using the changeset viewer.