Androidの写真画像のサイズ縮小

カメラで撮影した画像にイラストなどをオーバーレイして合成しようとしたら結果として位置がずれていた。
どうやら画面サイズと撮影した画像のサイズが異なることが原因。

BitmapFactory.OptionsのinSampleSizeの設定とかいじってみたが上手くいかなかったのでMatrixを使って縮小しImageViewにセットする方法で回避。とりあえずメモ

ImageView imageView =(ImageView)findViewById(R.id.hoge);
//MediaStoreより取得
String imgPath ="画像パス";   
//画面サイズ
int  screenWidth = getResources().getDisplayMetrics().widthPixels;
int  screenHeight = getResources().getDisplayMetrics().heightPixels;
FileInputStream fis = new FileInputStream(imgPath);
Bitmap orgBitmap = BitmapFactory.decodeStream(fis);
int orgWidth = orgBitmap.getWidth();
int orgHeight = orgBitmap.getHeight();
//縮尺比率
float scaleWidth = ((float) screenWidth) / orgWidth;
float scaleHeight = ((float)_screenHeight) / orgHeight;

Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap mainBitmap;
if( mainBmp != null){
    mainBmp.recycle();
}
mainBmp = Bitmap.createBitmap(orgBitmap, 0, 0,orgWidth, orgHeight, matrix, true);
imageView.setImageBitmap(mainBmp);