Skip to content

Commit 6c52e3d

Browse files
committed
Fix image resampling bug when outside grid limits (#85)
1 parent ee0107a commit 6c52e3d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

include/mapcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ mapcache_image* mapcache_image_create_with_data(mapcache_context *ctx, int width
889889
void mapcache_image_copy_resampled_nearest(mapcache_context *ctx, mapcache_image *src, mapcache_image *dst,
890890
double off_x, double off_y, double scale_x, double scale_y);
891891
void mapcache_image_copy_resampled_bilinear(mapcache_context *ctx, mapcache_image *src, mapcache_image *dst,
892-
double off_x, double off_y, double scale_x, double scale_y);
892+
double off_x, double off_y, double scale_x, double scale_y, int reflect_edges);
893893

894894

895895
/**

lib/image.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void mapcache_image_copy_resampled_nearest(mapcache_context *ctx, mapcache_image
233233
}
234234

235235
void mapcache_image_copy_resampled_bilinear(mapcache_context *ctx, mapcache_image *src, mapcache_image *dst,
236-
double off_x, double off_y, double scale_x, double scale_y)
236+
double off_x, double off_y, double scale_x, double scale_y, int reflect_edges)
237237
{
238238
#ifdef USE_PIXMAN
239239
pixman_image_t *si = pixman_image_create_bits(PIXMAN_a8r8g8b8,src->w,src->h,
@@ -244,7 +244,9 @@ void mapcache_image_copy_resampled_bilinear(mapcache_context *ctx, mapcache_imag
244244
pixman_transform_init_translate(&transform,pixman_double_to_fixed(-off_x),pixman_double_to_fixed(-off_y));
245245
pixman_transform_scale(&transform,NULL,pixman_double_to_fixed(1.0/scale_x),pixman_double_to_fixed(1.0/scale_y));
246246
pixman_image_set_transform (si, &transform);
247-
pixman_image_set_repeat (si, PIXMAN_REPEAT_REFLECT);
247+
if(reflect_edges) {
248+
pixman_image_set_repeat (si, PIXMAN_REPEAT_REFLECT);
249+
}
248250
pixman_image_set_filter(si,PIXMAN_FILTER_BILINEAR, NULL, 0);
249251
pixman_image_composite (PIXMAN_OP_OVER, si, NULL, bi,
250252
0, 0, 0, 0, 0, 0, dst->w,dst->h);

lib/tileset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mapcache_image* mapcache_tileset_assemble_map_tiles(mapcache_context *ctx, mapca
340340
} else {
341341
switch(mode) {
342342
case MAPCACHE_RESAMPLE_BILINEAR:
343-
mapcache_image_copy_resampled_bilinear(ctx,srcimage,image,dstminx,dstminy,hf,vf);
343+
mapcache_image_copy_resampled_bilinear(ctx,srcimage,image,dstminx,dstminy,hf,vf,0);
344344
break;
345345
default:
346346
mapcache_image_copy_resampled_nearest(ctx,srcimage,image,dstminx,dstminy,hf,vf);
@@ -691,7 +691,7 @@ void mapcache_tileset_assemble_out_of_zoom_tile(mapcache_context *ctx, mapcache_
691691
* ctx->log(ctx, MAPCACHE_DEBUG, "factor: %g. start: %g,%g (im size: %g)",scalefactor,dstminx,dstminy,scalefactor*256);
692692
*/
693693
if(scalefactor <= tile->grid_link->grid->tile_sx/2) /*FIXME: might fail for non-square tiles, also check tile_sy */
694-
mapcache_image_copy_resampled_bilinear(ctx,childtile->raw_image,tile->raw_image,dstminx,dstminy,scalefactor,scalefactor);
694+
mapcache_image_copy_resampled_bilinear(ctx,childtile->raw_image,tile->raw_image,dstminx,dstminy,scalefactor,scalefactor,1);
695695
else {
696696
/* no use going through bilinear resampling if the requested scalefactor maps less than 4 pixels onto the
697697
* resulting tile, plus pixman has some rounding bugs in this case, see

0 commit comments

Comments
 (0)