summaryrefslogtreecommitdiff
path: root/navit/android
diff options
context:
space:
mode:
authormdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220>2015-07-05 15:00:40 +0000
committermdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220>2015-07-05 15:00:40 +0000
commit8f5e64c2bfe8fab54b09cbb2c6af40f00b8deab8 (patch)
treef816b1e55fccd1770e725a00ede27cbf3b9a007a /navit/android
parent435c0a8d02ad4adc96394e444ba6322ac7ce95b4 (diff)
downloadnavit-8f5e64c2bfe8fab54b09cbb2c6af40f00b8deab8.tar.gz
Add:port_android:Support raster maps on Android as described in #1285.|Thank you jandegr
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@6126 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/android')
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index ef73a5449..fc4944240 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -27,6 +27,7 @@ import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
@@ -931,6 +932,48 @@ public class NavitGraphics
draw_canvas.drawBitmap(bitmap, x, y, paint);
}
+ /* takes an image and draws it on the screen as a prerendered maptile
+ *
+ *
+ *
+ * @param paint Paint object used to draw the image
+ * @param count the number of points specified
+ * @param p0x and p0y specifying the top left point
+ * @param p1x and p1y specifying the top right point
+ * @param p2x and p2y specifying the bottom left point, not yet used but kept
+ * for compatibility with the linux port
+ * @param bitmap Bitmap object holding the image to draw
+ *
+ * TODO make it work with 4 points specified to make it work for 3D mapview, so it can be used
+ * for small but very detailed maps as well as for large maps with very little detail but large
+ * coverage.
+ * TODO make it work with rectangular tiles as well ?
+ */
+ protected void draw_image_warp(Paint paint, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y, Bitmap bitmap)
+ {
+
+ float width;
+ float scale;
+ float deltaY;
+ float deltaX;
+ float angle;
+ Matrix matrix;
+
+ if (count == 3)
+ {
+ matrix = new Matrix();
+ deltaX = p1x - p0x;
+ deltaY = p1y - p0y;
+ width = (float) (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)));
+ angle = (float) (Math.atan2(deltaY, deltaX) * 180d / Math.PI);
+ scale = width / bitmap.getWidth();
+ matrix.preScale(scale, scale);
+ matrix.postTranslate(p0x, p0y);
+ matrix.postRotate(angle, p0x, p0y);
+ draw_canvas.drawBitmap(bitmap, matrix, paint);
+ }
+ }
+
/* These constants must be synchronized with enum draw_mode_num in graphics.h. */
public static final int draw_mode_begin = 0;
public static final int draw_mode_end = 1;