2
カメラの意図から画像を撮影していますが、ポートレートモードで画像を撮っても風景モードになります。画像を回転しようとしているとき:方法を解決できませんmtx.postRotate(int)
これを解決するために、画像を回転させようとしましたが、このエラーが発生しました(下記参照)。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
int screenWidth = getResources().getDisplayMetrics().widthPixels;
int screenHeight = getResources().getDisplayMetrics().heightPixels;
File imgFile = new File(pictureImagePath);
if(imgFile.exists()){
Bitmap bm = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
//Rotate image
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
// Notice that width and height are reversed
Bitmap scaled = ScalingUtilities.createScaledBitmap(bm, screenHeight, screenWidth, ScalingUtilities.ScalingLogic.FIT);
int w = scaled.getWidth();
int h = scaled.getHeight();
// Setting post rotate to 90
Matrix mtx = new Matrix();
mtx.postRotate(90); //Cannot resolve method 'postRotate(int)'
// Rotating Bitmap
bm = Bitmap.createBitmap(scaled, 0, 0, w, h, mtx, true);
}else{// LANDSCAPE MODE
//No need to reverse width and height
Bitmap scaled = ScalingUtilities.createScaledBitmap(bm, screenHeight, screenWidth, ScalingUtilities.ScalingLogic.FIT);
bm=scaled;
}
ImageView myImage = (ImageView) findViewById(R.id.imageView);
myImage.setImageBitmap(bm);
}
}
問題:mtx.postRotate(90);
が表示されている:メソッドを解決できません 'postRotate(int型)'
任意の助けを?
気軽に編集を提案してください。どんな助けもありがとうございます。
'Bitmap.createBitmap'のパラメータタイプを参照してください – pskink
@pskinkこれはエラーも表示していますが、それを把握することはできません。あなたは精緻化できますか? –
'Bitmap.createBitmap' 6番目のパラメータ(' Matrix m')をチェックし、それを 'mtx'と比較してください。 – pskink