Changeset 1676

Show
Ignore:
Timestamp:
03/11/10 10:20:04 (5 months ago)
Author:
artem
Message:

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

Location:
branches/0.7.1-dev
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.7.1-dev/include/mapnik/global.hpp

    r1445 r1676  
    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 
  • branches/0.7.1-dev/include/mapnik/graphics.hpp

    r1492 r1676  
    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) ; 
  • branches/0.7.1-dev/include/mapnik/image_util.hpp

    r1655 r1676  
    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 
     
    407407      int tw2 = target_width/2; 
    408408      int th2 = target_height/2; 
    409       int offs_x = int(round((source_width-target_width-x_off_f*2*source_width)/2)); 
    410       int offs_y = int(round((source_height-target_height-y_off_f*2*source_height)/2)); 
     409      int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2); 
     410      int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2); 
    411411      unsigned yprt, yprt1, xprt, xprt1; 
    412412 
  • branches/0.7.1-dev/src/agg_renderer.cpp

    r1655 r1676  
    7474#include <iostream> 
    7575#endif 
     76 
     77#include <cmath> 
    7678 
    7779namespace mapnik 
     
    571573                            { 
    572574                                //pixmap_.set_rectangle_alpha(px,py,*data); 
    573                                 pixmap_.set_rectangle_alpha2(*data,px,py,sym.get_opacity()); 
     575                                pixmap_.set_rectangle_alpha2(*data,px,py,float(sym.get_opacity())); 
    574576                                Envelope<double> dim = ren.prepare_glyphs(&text_placement.placements[0]); 
    575577                                ren.render(x,y); 
     
    715717      { 
    716718         Envelope<double> ext=t_.forward(raster->ext_); 
    717          int start_x = int(round(ext.minx())); 
    718          int start_y = int(round(ext.miny())); 
    719          int raster_width = int(round(ext.width())); 
    720          int raster_height = int(round(ext.height())); 
     719         int start_x = rint(ext.minx()); 
     720         int start_y = rint(ext.miny()); 
     721         int raster_width = rint(ext.width()); 
     722         int raster_height = rint(ext.height()); 
    721723         int end_x = start_x + raster_width; 
    722724         int end_y = start_y + raster_height;