+/**
+ *
+ */
+gboolean try_draw_scale_down (VikMapsLayer *vml, VikViewport *vvp, MapCoord ulm, gint xx, gint yy, gint tilesize_x_ceil, gint tilesize_y_ceil,
+ gdouble xshrinkfactor, gdouble yshrinkfactor, guint id, const gchar *mapname, gchar *path_buf, guint max_path_len)
+{
+ GdkPixbuf *pixbuf;
+ int scale_inc;
+ for (scale_inc = 1; scale_inc < SCALE_INC_DOWN; scale_inc ++) {
+ // Try with smaller zooms
+ int scale_factor = 1 << scale_inc; /* 2^scale_inc */
+ MapCoord ulm2 = ulm;
+ ulm2.x = ulm.x / scale_factor;
+ ulm2.y = ulm.y / scale_factor;
+ ulm2.scale = ulm.scale + scale_inc;
+ pixbuf = get_pixbuf ( vml, id, mapname, &ulm2, path_buf, max_path_len, xshrinkfactor * scale_factor, yshrinkfactor * scale_factor );
+ if ( pixbuf ) {
+ gint src_x = (ulm.x % scale_factor) * tilesize_x_ceil;
+ gint src_y = (ulm.y % scale_factor) * tilesize_y_ceil;
+ vik_viewport_draw_pixbuf ( vvp, pixbuf, src_x, src_y, xx, yy, tilesize_x_ceil, tilesize_y_ceil );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ *
+ */
+gboolean try_draw_scale_up (VikMapsLayer *vml, VikViewport *vvp, MapCoord ulm, gint xx, gint yy, gint tilesize_x_ceil, gint tilesize_y_ceil,
+ gdouble xshrinkfactor, gdouble yshrinkfactor, guint id, const gchar *mapname, gchar *path_buf, guint max_path_len)
+{
+ GdkPixbuf *pixbuf;
+ // Try with bigger zooms
+ int scale_dec;
+ for (scale_dec = 1; scale_dec < SCALE_INC_UP; scale_dec ++) {
+ int pict_x, pict_y;
+ int scale_factor = 1 << scale_dec; /* 2^scale_dec */
+ MapCoord ulm2 = ulm;
+ ulm2.x = ulm.x * scale_factor;
+ ulm2.y = ulm.y * scale_factor;
+ ulm2.scale = ulm.scale - scale_dec;
+ for (pict_x = 0; pict_x < scale_factor; pict_x ++) {
+ for (pict_y = 0; pict_y < scale_factor; pict_y ++) {
+ MapCoord ulm3 = ulm2;
+ ulm3.x += pict_x;
+ ulm3.y += pict_y;
+ pixbuf = get_pixbuf ( vml, id, mapname, &ulm3, path_buf, max_path_len, xshrinkfactor / scale_factor, yshrinkfactor / scale_factor );
+ if ( pixbuf ) {
+ gint src_x = 0;
+ gint src_y = 0;
+ gint dest_x = xx + pict_x * (tilesize_x_ceil / scale_factor);
+ gint dest_y = yy + pict_y * (tilesize_y_ceil / scale_factor);
+ vik_viewport_draw_pixbuf ( vvp, pixbuf, src_x, src_y, dest_x, dest_y, tilesize_x_ceil / scale_factor, tilesize_y_ceil / scale_factor );
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+