Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

import android.view.View;

public class Main {
    public static float[] convertViewXYintoBitmapXY(int height, int weight, Bitmap bitmap, float x, float y) {
        float imgHeight = height;
        float imgWidth = weight;
        float bmHeight = bitmap.getHeight();
        float bmWidth = bitmap.getWidth();

        float WidthRatio = bmWidth / imgWidth;
        float HeightRatio = bmHeight / imgHeight;

        float BitmapPixelX = x * WidthRatio;
        float BitmapPixelY = y * HeightRatio;

        float[] bitmapXY = new float[] { BitmapPixelX, BitmapPixelY };
        return bitmapXY;
    }

    public static float[] convertViewXYintoBitmapXY(View view, Bitmap bitmap, float x, float y) {
        float imgHeight = view.getHeight();
        float imgWidth = view.getWidth();
        float bmHeight = bitmap.getHeight();
        float bmWidth = bitmap.getWidth();

        float WidthRatio = bmWidth / imgWidth;
        float HeightRatio = bmHeight / imgHeight;

        float BitmapPixelX = x * WidthRatio;
        float BitmapPixelY = y * HeightRatio;

        float[] bitmapXY = new float[] { BitmapPixelX, BitmapPixelY };
        return bitmapXY;
    }
}