웹 페이지의 이미지를 다시 배치하는 사용자 정의 ImageView
이 있습니다. 전화 화면에 표시되는 이미지는 웹 페이지의 이미지를 나타냅니다.Android 이미지 좌표 가져 오기
이미지를 올바르게 프레임 화하기 위해 이미지의 크기를 조정할 때 얼마만큼 이미지가 오프셋되는지 알아 보려면 Matrix.mapPoints(float[] dst, float[] src)
을 사용하고 있습니다. 또한 이미지의 크기를 조정하는 방법과 웹 페이지의 이미지 태그 너비와 비교하여 전화의 이미지보기 크기를 고려합니다. 이미지 뷰 클래스에서
UpdateImage()
public void updateImage() {
final float phoneDisplayScale = (float) getWidth()/(float) getDrawable().getIntrinsicWidth();
float[] m = new float[9];
matrix.getValues(m);
float scale = m[Matrix.MSCALE_X];
float[] arr = {0, 0};
matrix.mapPoints(arr, arr);
//holder.rect = {image_x, image_y, imageWidth, imageHeight}
if (holder != null) {
holder.getRect()[0] = arr[0]/phoneDisplayScale;
holder.getRect()[1] = arr[1]/phoneDisplayScale;
holder.getRect()[2] = scale * (getImageWidth()/phoneDisplayScale);
holder.getRect()[3] = scale * (getImageHeight()/phoneDisplayScale);
Log.i(TAG, "doInBackground: " + Arrays.toString(holder.getRect()));
Log.i(TAG, "doInBackground: " + Arrays.toString(holder.getRect()));
Log.i(TAG, "doInBackground: " + Arrays.toString(holder.getRect()));
}
//
//
// Socket io code
//
//
}
이미지 크기를 조절하고 이미지의 왼쪽이 ImageView
의 왼쪽 상단에 있도록 정렬 될 때이 작동하지만, 당신이 할 수있는 절대로 이미지의 오른쪽 아래를 확대하지 마십시오. 나는 또한 map points 메소드가 이미지의 너비와 높이 (빼기 값)를 반환한다는 것을 max로 확대하면 알 수있다.