{"id":1416,"date":"2013-04-09T11:16:15","date_gmt":"2013-04-09T05:46:15","guid":{"rendered":"http:\/\/judepereira.com\/blog\/?p=1416"},"modified":"2013-07-30T21:37:29","modified_gmt":"2013-07-30T16:07:29","slug":"multi-touch-in-android-translate-scale-and-rotate","status":"publish","type":"post","link":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/","title":{"rendered":"Multi Touch in Android &#8211; Translate, Scale, and Rotate"},"content":{"rendered":"<p>Here&#8217;s a quick and easy implementation of Android&#8217;s multi touch feature &#8211; one finger to move, two to zoom, and three to rotate the image.<\/p>\n<p>Assuming you have a basic understanding of 2D matrix transformations, the <a title=\"Matrix | Android Developers\" href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/Matrix.html\" target=\"_blank\">Matrix<\/a> class in Android uses a 3&#215;3 matrix to achieve all of the 2D transformations.<\/p>\n<p>The source code and pre -built APK is available. See the end of this post.<\/p>\n<p>Main activity &#8211; MultiTouch.java<br \/>\n[code language=&#8221;java&#8221;]<br \/>\npackage com.multitouch.example;<\/p>\n<p>import android.app.Activity;<br \/>\nimport android.graphics.Matrix;<br \/>\nimport android.graphics.PointF;<br \/>\nimport android.os.Bundle;<br \/>\nimport android.util.FloatMath;<br \/>\nimport android.view.MotionEvent;<br \/>\nimport android.view.View;<br \/>\nimport android.view.View.OnTouchListener;<br \/>\nimport android.widget.ImageView;<\/p>\n<p>public class MultiTouch extends Activity implements OnTouchListener {<\/p>\n<p>    \/\/ these matrices will be used to move and zoom image<br \/>\n    private Matrix matrix = new Matrix();<br \/>\n    private Matrix savedMatrix = new Matrix();<br \/>\n    \/\/ we can be in one of these 3 states<br \/>\n    private static final int NONE = 0;<br \/>\n    private static final int DRAG = 1;<br \/>\n    private static final int ZOOM = 2;<br \/>\n    private int mode = NONE;<br \/>\n    \/\/ remember some things for zooming<br \/>\n    private PointF start = new PointF();<br \/>\n    private PointF mid = new PointF();<br \/>\n    private float oldDist = 1f;<br \/>\n    private float d = 0f;<br \/>\n    private float newRot = 0f;<br \/>\n    private float[] lastEvent = null;<\/p>\n<p>    @Override<br \/>\n    public void onCreate(Bundle savedInstanceState) {<br \/>\n        super.onCreate(savedInstanceState);<br \/>\n        setContentView(R.layout.main);<br \/>\n        ImageView view = (ImageView) findViewById(R.id.imageView);<br \/>\n        view.setOnTouchListener(this);<br \/>\n    }<\/p>\n<p>    public boolean onTouch(View v, MotionEvent event) {<br \/>\n        \/\/ handle touch events here<br \/>\n        ImageView view = (ImageView) v;<br \/>\n        switch (event.getAction() &#038; MotionEvent.ACTION_MASK) {<br \/>\n            case MotionEvent.ACTION_DOWN:<br \/>\n                savedMatrix.set(matrix);<br \/>\n                start.set(event.getX(), event.getY());<br \/>\n                mode = DRAG;<br \/>\n                lastEvent = null;<br \/>\n                break;<br \/>\n            case MotionEvent.ACTION_POINTER_DOWN:<br \/>\n                oldDist = spacing(event);<br \/>\n                if (oldDist > 10f) {<br \/>\n                    savedMatrix.set(matrix);<br \/>\n                    midPoint(mid, event);<br \/>\n                    mode = ZOOM;<br \/>\n                }<br \/>\n                lastEvent = new float[4];<br \/>\n                lastEvent[0] = event.getX(0);<br \/>\n                lastEvent[1] = event.getX(1);<br \/>\n                lastEvent[2] = event.getY(0);<br \/>\n                lastEvent[3] = event.getY(1);<br \/>\n                d = rotation(event);<br \/>\n                break;<br \/>\n            case MotionEvent.ACTION_UP:<br \/>\n            case MotionEvent.ACTION_POINTER_UP:<br \/>\n                mode = NONE;<br \/>\n                lastEvent = null;<br \/>\n                break;<br \/>\n            case MotionEvent.ACTION_MOVE:<br \/>\n                if (mode == DRAG) {<br \/>\n                    matrix.set(savedMatrix);<br \/>\n                    float dx = event.getX() &#8211; start.x;<br \/>\n                    float dy = event.getY() &#8211; start.y;<br \/>\n                    matrix.postTranslate(dx, dy);<br \/>\n                } else if (mode == ZOOM) {<br \/>\n                    float newDist = spacing(event);<br \/>\n                    if (newDist > 10f) {<br \/>\n                        matrix.set(savedMatrix);<br \/>\n                        float scale = (newDist \/ oldDist);<br \/>\n                        matrix.postScale(scale, scale, mid.x, mid.y);<br \/>\n                    }<br \/>\n                    if (lastEvent != null &#038;&#038; event.getPointerCount() == 3) {<br \/>\n                        newRot = rotation(event);<br \/>\n                        float r = newRot &#8211; d;<br \/>\n                        float[] values = new float[9];<br \/>\n                        matrix.getValues(values);<br \/>\n                        float tx = values[2];<br \/>\n                        float ty = values[5];<br \/>\n                        float sx = values[0];<br \/>\n                        float xc = (view.getWidth() \/ 2) * sx;<br \/>\n                        float yc = (view.getHeight() \/ 2) * sx;<br \/>\n                        matrix.postRotate(r, tx + xc, ty + yc);<br \/>\n                    }<br \/>\n                }<br \/>\n                break;<br \/>\n        }<\/p>\n<p>        view.setImageMatrix(matrix);<br \/>\n        return true;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Determine the space between the first two fingers<br \/>\n     *\/<br \/>\n    private float spacing(MotionEvent event) {<br \/>\n        float x = event.getX(0) &#8211; event.getX(1);<br \/>\n        float y = event.getY(0) &#8211; event.getY(1);<br \/>\n        return FloatMath.sqrt(x * x + y * y);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Calculate the mid point of the first two fingers<br \/>\n     *\/<br \/>\n    private void midPoint(PointF point, MotionEvent event) {<br \/>\n        float x = event.getX(0) + event.getX(1);<br \/>\n        float y = event.getY(0) + event.getY(1);<br \/>\n        point.set(x \/ 2, y \/ 2);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Calculate the degree to be rotated by.<br \/>\n     *<br \/>\n     * @param event<br \/>\n     * @return Degrees<br \/>\n     *\/<br \/>\n    private float rotation(MotionEvent event) {<br \/>\n        double delta_x = (event.getX(0) &#8211; event.getX(1));<br \/>\n        double delta_y = (event.getY(0) &#8211; event.getY(1));<br \/>\n        double radians = Math.atan2(delta_y, delta_x);<br \/>\n        return (float) Math.toDegrees(radians);<br \/>\n    }<br \/>\n}<br \/>\n[\/code]<br \/>\nAn important function that is always used is postXx(). This function concats a new matrix of the type Xx to the existing matrix object. Using setXx() will reset the matrix&#8217;s Xx property.<br \/>\nMain layout &#8211; main.xml<br \/>\n[code language=&#8221;xml&#8221;]<br \/>\n<?xml version=\"1.0\" encoding=\"utf-8\"?><\/p>\n<p><FrameLayout\nxmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\nandroid:layout_width=\"fill_parent\"\nandroid:layout_height=\"fill_parent\"><\/p>\n<p><ImageView android:id=\"@+id\/imageView\"\nandroid:layout_width=\"fill_parent\"\nandroid:layout_height=\"fill_parent\"\nandroid:src=\"@drawable\/butterfly\"\nandroid:scaleType=\"matrix\" \/><\/p>\n<p><\/FrameLayout><br \/>\n[\/code]<\/p>\n<p>Browse and download the source code on <a title=\"Multi Touch example on GitHub\" href=\"https:\/\/github.com\/judepereira\/android-multitouch\" target=\"_blank\">GitHub.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a quick and easy implementation of Android&#8217;s multi touch feature &#8211; one finger to move, two to zoom, and three to rotate the image. Assuming you have a basic understanding of 2D matrix transformations, the Matrix class in Android uses a 3&#215;3 matrix to achieve all of the 2D transformations. The source code and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[401],"tags":[446,556,445,447,75,442,443,444,435,437,440,438,436,439,441],"class_list":["post-1416","post","type-post","status-publish","format-standard","hentry","category-android","tag-2d-transformation","tag-android","tag-biitmap","tag-example","tag-image","tag-image-view","tag-imageview","tag-matrix","tag-multi","tag-multi-touch","tag-rotate","tag-scale","tag-touch","tag-translate","tag-view"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"Here&#039;s a quick and easy implementation of Android&#039;s multi touch feature - one finger to move, two to zoom, and three to rotate the image.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Jude Pereira\"\/>\n\t<meta name=\"keywords\" content=\"android,multi,touch,multi touch,scale,translate,rotate,image,view,image view,imageview,matrix,biitmap,2d transformation,example\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"@judepereira | Fleeting Thoughts\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira\" \/>\n\t\t<meta property=\"og:description\" content=\"Here&#039;s a quick and easy implementation of Android&#039;s multi touch feature - one finger to move, two to zoom, and three to rotate the image.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-04-09T05:46:15+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-07-30T16:07:29+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@judebpereira\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Here&#039;s a quick and easy implementation of Android&#039;s multi touch feature - one finger to move, two to zoom, and three to rotate the image.\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@judebpereira\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#article\",\"name\":\"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira\",\"headline\":\"Multi Touch in Android &#8211; Translate, Scale, and Rotate\",\"author\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#articleImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g\",\"width\":96,\"height\":96,\"caption\":\"Jude Pereira\"},\"datePublished\":\"2013-04-09T11:16:15+05:30\",\"dateModified\":\"2013-07-30T21:37:29+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":61,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#webpage\"},\"articleSection\":\"android, 2d transformation, android, biitmap, example, image, image view, imageview, matrix, multi, multi touch, rotate, scale, touch, translate, view\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/#listItem\",\"name\":\"another snippet | code\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/#listItem\",\"position\":2,\"name\":\"another snippet | code\",\"item\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/android\\\/#listItem\",\"name\":\"android\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/android\\\/#listItem\",\"position\":3,\"name\":\"android\",\"item\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/android\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#listItem\",\"name\":\"Multi Touch in Android &#8211; Translate, Scale, and Rotate\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/#listItem\",\"name\":\"another snippet | code\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#listItem\",\"position\":4,\"name\":\"Multi Touch in Android &#8211; Translate, Scale, and Rotate\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/category\\\/code\\\/android\\\/#listItem\",\"name\":\"android\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#person\",\"name\":\"Jude Pereira\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g\",\"width\":96,\"height\":96,\"caption\":\"Jude Pereira\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Jude Pereira\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g\",\"width\":96,\"height\":96,\"caption\":\"Jude Pereira\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#webpage\",\"url\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/\",\"name\":\"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira\",\"description\":\"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/multi-touch-in-android-translate-scale-and-rotate\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2013-04-09T11:16:15+05:30\",\"dateModified\":\"2013-07-30T21:37:29+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/\",\"name\":\"@judepereira\",\"description\":\"Fleeting Thoughts\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/judepereira.com\\\/blog\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira","description":"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.","canonical_url":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/","robots":"max-image-preview:large","keywords":"android,multi,touch,multi touch,scale,translate,rotate,image,view,image view,imageview,matrix,biitmap,2d transformation,example","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#article","name":"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira","headline":"Multi Touch in Android &#8211; Translate, Scale, and Rotate","author":{"@id":"https:\/\/judepereira.com\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/judepereira.com\/blog\/#person"},"image":{"@type":"ImageObject","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#articleImage","url":"https:\/\/secure.gravatar.com\/avatar\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g","width":96,"height":96,"caption":"Jude Pereira"},"datePublished":"2013-04-09T11:16:15+05:30","dateModified":"2013-07-30T21:37:29+05:30","inLanguage":"en-US","commentCount":61,"mainEntityOfPage":{"@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#webpage"},"isPartOf":{"@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#webpage"},"articleSection":"android, 2d transformation, android, biitmap, example, image, image view, imageview, matrix, multi, multi touch, rotate, scale, touch, translate, view"},{"@type":"BreadcrumbList","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/judepereira.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/#listItem","name":"another snippet | code"}},{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/#listItem","position":2,"name":"another snippet | code","item":"https:\/\/judepereira.com\/blog\/category\/code\/","nextItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/android\/#listItem","name":"android"},"previousItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/android\/#listItem","position":3,"name":"android","item":"https:\/\/judepereira.com\/blog\/category\/code\/android\/","nextItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#listItem","name":"Multi Touch in Android &#8211; Translate, Scale, and Rotate"},"previousItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/#listItem","name":"another snippet | code"}},{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#listItem","position":4,"name":"Multi Touch in Android &#8211; Translate, Scale, and Rotate","previousItem":{"@type":"ListItem","@id":"https:\/\/judepereira.com\/blog\/category\/code\/android\/#listItem","name":"android"}}]},{"@type":"Person","@id":"https:\/\/judepereira.com\/blog\/#person","name":"Jude Pereira","image":{"@type":"ImageObject","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g","width":96,"height":96,"caption":"Jude Pereira"}},{"@type":"Person","@id":"https:\/\/judepereira.com\/blog\/author\/admin\/#author","url":"https:\/\/judepereira.com\/blog\/author\/admin\/","name":"Jude Pereira","image":{"@type":"ImageObject","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0a1089f1857938099c95297539cf443242d71c86831e7fa280fdb2a8ff57c360?s=96&r=g","width":96,"height":96,"caption":"Jude Pereira"}},{"@type":"WebPage","@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#webpage","url":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/","name":"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira","description":"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/judepereira.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/#breadcrumblist"},"author":{"@id":"https:\/\/judepereira.com\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/judepereira.com\/blog\/author\/admin\/#author"},"datePublished":"2013-04-09T11:16:15+05:30","dateModified":"2013-07-30T21:37:29+05:30"},{"@type":"WebSite","@id":"https:\/\/judepereira.com\/blog\/#website","url":"https:\/\/judepereira.com\/blog\/","name":"@judepereira","description":"Fleeting Thoughts","inLanguage":"en-US","publisher":{"@id":"https:\/\/judepereira.com\/blog\/#person"}}]},"og:locale":"en_US","og:site_name":"@judepereira | Fleeting Thoughts","og:type":"article","og:title":"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira","og:description":"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.","og:url":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/","og:image":"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png","og:image:secure_url":"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png","og:image:width":512,"og:image:height":512,"article:published_time":"2013-04-09T05:46:15+00:00","article:modified_time":"2013-07-30T16:07:29+00:00","twitter:card":"summary","twitter:site":"@judebpereira","twitter:title":"Multi Touch in Android - Translate, Scale, and Rotate | @judepereira","twitter:description":"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.","twitter:creator":"@judebpereira","twitter:image":"https:\/\/judepereira.com\/blog\/wp-content\/uploads\/cropped-foo.png"},"aioseo_meta_data":{"post_id":"1416","title":"Multi Touch in Android - Translate, Scale, and Rotate | #site_title","description":"Here's a quick and easy implementation of Android's multi touch feature - one finger to move, two to zoom, and three to rotate the image.","keywords":[{"label":"android","value":"android"},{"label":"multi","value":"multi"},{"label":"touch","value":"touch"},{"label":"multi touch","value":"multi touch"},{"label":"scale","value":"scale"},{"label":"translate","value":"translate"},{"label":"rotate","value":"rotate"},{"label":"image","value":"image"},{"label":"view","value":"view"},{"label":"image view","value":"image view"},{"label":"imageview","value":"imageview"},{"label":"matrix","value":"matrix"},{"label":"biitmap","value":"biitmap"},{"label":"2d transformation","value":"2d transformation"},{"label":"example","value":"example"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-25 19:05:22","updated":"2025-06-03 20:09:11","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/judepereira.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/judepereira.com\/blog\/category\/code\/\" title=\"another snippet | code\">another snippet | code<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/judepereira.com\/blog\/category\/code\/android\/\" title=\"android\">android<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tMulti Touch in Android \u2013 Translate, Scale, and Rotate\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/judepereira.com\/blog\/"},{"label":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},{"label":"android","link":"https:\/\/judepereira.com\/blog\/category\/code\/android\/"},{"label":"Multi Touch in Android &#8211; Translate, Scale, and Rotate","link":"https:\/\/judepereira.com\/blog\/multi-touch-in-android-translate-scale-and-rotate\/"}],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pqtyx-mQ","jetpack-related-posts":[{"id":1713,"url":"https:\/\/judepereira.com\/blog\/a-letter-to-tim-cook-regarding-ios-10-with-love-for-apple\/","url_meta":{"origin":1416,"position":0},"title":"A letter to Tim Cook regarding iOS 10, with love for Apple","author":"Jude Pereira","date":"June 17, 2016","format":false,"excerpt":"Tim, iOS has always been known for it's user interface, until recently. Your new take on notifications have not only made them very loud, and unsettling, but do not flow with the entire look and feel of Apple: No Mr. Tim, no. My notifications aren't waiting for me. They're crying\u2026","rel":"","context":"In &quot;life!&quot;","block_context":{"text":"life!","link":"https:\/\/judepereira.com\/blog\/category\/living-a-wonder\/"},"img":{"alt_text":"No Mr. Tim, no. My notifications will not be waiting for me. They're crying out for my attention.","src":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-06-17-at-08.49.59-614x1024.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-06-17-at-08.49.59-614x1024.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-06-17-at-08.49.59-614x1024.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1778,"url":"https:\/\/judepereira.com\/blog\/letstuneup-a-music-chart-with-arjit-singh-in-the-lead\/","url_meta":{"origin":1416,"position":1},"title":"LetsTuneup: A music chart with Arjit Singh in the lead","author":"Jude Pereira","date":"April 28, 2017","format":false,"excerpt":"LetsTuneup has grown tremendously, and with it, we've introduced new features too. We identified that a few of our users couldn't use the app to it's full extent because they didn't have music on their devices. We've solved that. Users can now pick their favourite artists, powered by a location\u2026","rel":"","context":"In &quot;android&quot;","block_context":{"text":"android","link":"https:\/\/judepereira.com\/blog\/category\/code\/android\/"},"img":{"alt_text":"Arjit Singh in the lead, with Eminem, Linking Park, Coldplay and Pink Floyd following close","src":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/artists.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1734,"url":"https:\/\/judepereira.com\/blog\/why-matchbox-and-how-it-connects-people-through-music\/","url_meta":{"origin":1416,"position":2},"title":"Why Matchbox, and how it connects people through music","author":"Jude Pereira","date":"January 21, 2017","format":false,"excerpt":"There's no doubt that music defines us. It influences our moods, for example, making us happy by releasing a chemical named dopamine. It can affect what we wear, what we eat, and perhaps even who we enjoy being together with. It affects\u00a0our thought process too (it's well known that ambient\u2026","rel":"","context":"In &quot;android&quot;","block_context":{"text":"android","link":"https:\/\/judepereira.com\/blog\/category\/code\/android\/"},"img":{"alt_text":"Matchbox showing the top 10 artists","src":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/IMG_7195-300x210.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":893,"url":"https:\/\/judepereira.com\/blog\/coloured-varlogmessages-at-tty12\/","url_meta":{"origin":1416,"position":3},"title":"Coloured \/var\/log\/messages at tty12","author":"Jude Pereira","date":"April 26, 2011","format":false,"excerpt":"Reading logs could never become any more easier, at just a keystroke, you have your logs displayed where you want, in some fancy colour. They look great too. TTY's can be accessed by pressing Alt + Ctrl + F[1 - 12] simultaneously. In the following, you'll get a decent, colourized\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/comments?post=1416"}],"version-history":[{"count":9,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1416\/revisions"}],"predecessor-version":[{"id":1505,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1416\/revisions\/1505"}],"wp:attachment":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/media?parent=1416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/categories?post=1416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/tags?post=1416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}