+ use rint(v) instead of int(round(v))
+ add rint implementation - msvc hasn't got one + minor cleanups
This commit is contained in:
parent
e62fb19c7c
commit
8b3c390ebf
4 changed files with 28 additions and 17 deletions
|
@ -159,6 +159,15 @@ namespace mapnik
|
|||
#endif
|
||||
return val;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS
|
||||
// msvc doesn't have rint in <cmath>
|
||||
inline int rint( double val)
|
||||
{
|
||||
return int(floor(val + 0.5));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif //GLOBAL_HPP
|
||||
|
|
|
@ -369,10 +369,10 @@ namespace mapnik
|
|||
unsigned g0 = (rgba0 >> 16 ) & 0xff;
|
||||
unsigned b0 = (rgba0 >> 8) & 0xff;
|
||||
|
||||
r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8);
|
||||
g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8);
|
||||
b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8);
|
||||
a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8));
|
||||
r0 = byte(((r1 - r0) * a1 + (r0 << 8)) >> 8);
|
||||
g0 = byte(((g1 - g0) * a1 + (g0 << 8)) >> 8);
|
||||
b0 = byte(((b1 - b0) * a1 + (b0 << 8)) >> 8);
|
||||
a0 = byte((a1 + a0) - ((a1 * a0 + 255) >> 8));
|
||||
|
||||
row_to[x] = (a0)| (b0 << 8) | (g0 << 16) | (r0 << 24) ;
|
||||
#else
|
||||
|
@ -387,10 +387,10 @@ namespace mapnik
|
|||
unsigned g0 = (rgba0 >> 8 ) & 0xff;
|
||||
unsigned b0 = (rgba0 >> 16) & 0xff;
|
||||
|
||||
r0 = uint8_t(((r1 - r0) * a1 + (r0 << 8)) >> 8);
|
||||
g0 = uint8_t(((g1 - g0) * a1 + (g0 << 8)) >> 8);
|
||||
b0 = uint8_t(((b1 - b0) * a1 + (b0 << 8)) >> 8);
|
||||
a0 = uint8_t((a1 + a0) - ((a1 * a0 + 255) >> 8));
|
||||
r0 = byte(((r1 - r0) * a1 + (r0 << 8)) >> 8);
|
||||
g0 = byte(((g1 - g0) * a1 + (g0 << 8)) >> 8);
|
||||
b0 = byte(((b1 - b0) * a1 + (b0 << 8)) >> 8);
|
||||
a0 = byte((a1 + a0) - ((a1 * a0 + 255) >> 8));
|
||||
|
||||
row_to[x] = (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ;
|
||||
#endif
|
||||
|
|
|
@ -319,8 +319,8 @@ namespace mapnik {
|
|||
int x=0,y=0,xs=0,ys=0;
|
||||
int tw2 = target_width/2;
|
||||
int th2 = target_height/2;
|
||||
int offs_x = int(round((source_width-target_width-x_off_f*2*source_width)/2));
|
||||
int offs_y = int(round((source_height-target_height-y_off_f*2*source_height)/2));
|
||||
int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2);
|
||||
int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2);
|
||||
unsigned yprt, yprt1, xprt, xprt1;
|
||||
|
||||
//no scaling or subpixel offset
|
||||
|
@ -406,8 +406,8 @@ namespace mapnik {
|
|||
int x=0,y=0,xs=0,ys=0;
|
||||
int tw2 = target_width/2;
|
||||
int th2 = target_height/2;
|
||||
int offs_x = int(round((source_width-target_width-x_off_f*2*source_width)/2));
|
||||
int offs_y = int(round((source_height-target_height-y_off_f*2*source_height)/2));
|
||||
int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2);
|
||||
int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2);
|
||||
unsigned yprt, yprt1, xprt, xprt1;
|
||||
|
||||
//no scaling or subpixel offset
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class pattern_source : private boost::noncopyable
|
||||
|
@ -570,7 +572,7 @@ namespace mapnik
|
|||
if ( sym.get_allow_overlap() || detector_.has_placement(label_ext) )
|
||||
{
|
||||
//pixmap_.set_rectangle_alpha(px,py,*data);
|
||||
pixmap_.set_rectangle_alpha2(*data,px,py,sym.get_opacity());
|
||||
pixmap_.set_rectangle_alpha2(*data,px,py,float(sym.get_opacity()));
|
||||
Envelope<double> dim = ren.prepare_glyphs(&text_placement.placements[0]);
|
||||
ren.render(x,y);
|
||||
detector_.insert(label_ext);
|
||||
|
@ -714,10 +716,10 @@ namespace mapnik
|
|||
if (raster)
|
||||
{
|
||||
Envelope<double> ext=t_.forward(raster->ext_);
|
||||
int start_x = int(round(ext.minx()));
|
||||
int start_y = int(round(ext.miny()));
|
||||
int raster_width = int(round(ext.width()));
|
||||
int raster_height = int(round(ext.height()));
|
||||
int start_x = rint(ext.minx());
|
||||
int start_y = rint(ext.miny());
|
||||
int raster_width = rint(ext.width());
|
||||
int raster_height = rint(ext.height());
|
||||
int end_x = start_x + raster_width;
|
||||
int end_y = start_y + raster_height;
|
||||
double err_offs_x = (ext.minx()-start_x + ext.maxx()-end_x)/2;
|
||||
|
|
Loading…
Reference in a new issue