Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;

import android.widget.ImageView;

public class Main {
    public static int[] mapBitmapCoordinatesFromImageView(int posX, int posY, ImageView imageView) {
        Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

        int ivW = imageView.getWidth();
        int ivH = imageView.getHeight();
        int bW = bitmap.getWidth();
        int bH = bitmap.getHeight();

        int newX = posX * bW / ivW;
        int newH = posY * bH / ivH;

        return new int[] { newX, newH };
    }
}