Changeset 1681

Show
Ignore:
Timestamp:
03/11/10 18:19:12 (5 months ago)
Author:
dane
Message:

+ use rint(v) instead of int(round(v)) + add rint implementation - msvc hasn't got one + minor cleanups

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/include/mapnik/global.hpp

    r1445 r1681  
    160160        return val; 
    161161    } 
     162 
     163#ifdef _WINDOWS 
     164// msvc doesn't have rint in <cmath> 
     165inline int rint( double val) 
     166{ 
     167    return int(floor(val + 0.5)); 
     168} 
     169#endif 
     170 
    162171} 
    163172 
  • trunk/include/mapnik/graphics.hpp

    r1495 r1681  
    370370                    unsigned b0 = (rgba0 >> 8) & 0xff; 
    371371 
    372                     r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8); 
    373                     g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8); 
    374                     b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8); 
    375                     a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8)); 
     372                    r0 = byte(((r1 - r0) * a1 + (r0 << 8)) >> 8); 
     373                    g0 = byte(((g1 - g0) * a1 + (g0 << 8)) >> 8); 
     374                    b0 = byte(((b1 - b0) * a1 + (b0 << 8)) >> 8); 
     375                    a0 = byte((a1 + a0) - ((a1 * a0 + 255) >> 8)); 
    376376 
    377377                    row_to[x] = (a0)| (b0 << 8) |  (g0 << 16) | (r0 << 24) ; 
     
    388388                    unsigned b0 = (rgba0 >> 16) & 0xff; 
    389389 
    390                     r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8); 
    391                     g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8); 
    392                     b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8); 
    393                     a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8)); 
     390                    r0 = byte(((r1 - r0) * a1 + (r0 << 8)) >> 8); 
     391                    g0 = byte(((g1 - g0) * a1 + (g0 << 8)) >> 8); 
     392                    b0 = byte(((b1 - b0) * a1 + (b0 << 8)) >> 8); 
     393                    a0 = byte((a1 + a0) - ((a1 * a0 + 255) >> 8)); 
    394394                     
    395395                    row_to[x] = (a0 << 24)| (b0 << 16) |  (g0 << 8) | (r0) ; 
  • trunk/include/mapnik/image_util.hpp

    r1656 r1681  
    233233    int tw2 = target_width/2; 
    234234    int th2 = target_height/2; 
    235     int offs_x = int(round((source_width-target_width-x_off_f*2*source_width)/2)); 
    236     int offs_y = int(round((source_height-target_height-y_off_f*2*source_height)/2)); 
     235    int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2); 
     236    int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2); 
    237237    unsigned yprt, yprt1, xprt, xprt1; 
    238238 
     
    320320    int tw2 = target_width/2; 
    321321    int th2 = target_height/2; 
    322     int offs_x = int(round((source_width-target_width-x_off_f*2*source_width)/2)); 
    323     int offs_y = int(round((source_height-target_height-y_off_f*2*source_height)/2)); 
     322    int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2); 
     323    int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2); 
    324324    unsigned yprt, yprt1, xprt, xprt1; 
    325325 
  • trunk/src/agg_renderer.cpp

    r1657 r1681  
    7676#include <iostream> 
    7777#endif 
     78 
     79#include <cmath> 
    7880 
    7981namespace mapnik 
     
    596598                                { 
    597599                                    //pixmap_.set_rectangle_alpha(px,py,*data); 
    598                                     pixmap_.set_rectangle_alpha2(*(*data),px,py,sym.get_opacity()); 
     600                                    pixmap_.set_rectangle_alpha2(*(*data),px,py,float(sym.get_opacity())); 
    599601                                    box2d<double> dim = ren.prepare_glyphs(&text_placement.placements[0]); 
    600602                                    ren.render(x,y); 
     
    750752        box2d<double> ext=t_.forward(raster->ext_); 
    751753         
    752         int start_x = int(round(ext.minx())); 
    753         int start_y = int(round(ext.miny())); 
    754         int raster_width = int(round(ext.width())); 
    755         int raster_height = int(round(ext.height())); 
     754        int start_x = rint(ext.minx()); 
     755        int start_y = rint(ext.miny()); 
     756        int raster_width = rint(ext.width()); 
     757        int raster_height = rint(ext.height()); 
    756758        int end_x = start_x + raster_width; 
    757759        int end_y = start_y + raster_height;