0
の画像を取得し、私はギャラリーやカメラから画像を取得するには、このコードを使用しています:アンドロイド:私たちがギャラリーに見るように私のアプリでは代わりにStratchイメージ
今@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 10 && resultCode == Activity.RESULT_OK) {
Uri contentUri = data.getData();
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
imagePath = cursor.getString(column_index);
//Bitmap croppedImage = BitmapFactory.decodeFile(imagePath);
tempBitmap = BitmapFactory.decodeFile(imagePath);
if(!(tempBitmap == null))
{
// here i am changing display to the tempBitmap
photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);
//photoBitmap = Bitmap.createBitmap(tempBitmap, 0, 0, tempBitmap.getWidth(), tempBitmap.getHeight());
takePhotoFromGallery = true;// edited
}
else
Toast.makeText(getApplicationContext(), "Image is not valid", Toast.LENGTH_SHORT).show();
}
if(resultCode == RESULT_OK && requestCode==TAKE_PHOTO_CODE){
final File file = getTempFile(this);
try {
tempBitmap = Media.getBitmap(getContentResolver(), Uri.fromFile(file));
photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);
takePhotoFromCamera = true;
// do whatever you want with the bitmap (Resize, Rename, Add To Gallery, etc)
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
、すべてが正常に動作します。しかし私はイメージをStratとして得た。
私は、この行ので、それがあるthaught:
photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);
は、ここで私は画像の幅、ディスプレイの幅と高さ、高さをstratchingています。
私は、ギャラリーにthewイメージを正常に表示できるので、ImageがDispalyである必要があります。どのようにそれを可能にするか???
これは私がカメラからsnapingいた画像です:
そして今、これは私が自分のアプリケーションに表示何ですか:
今第2の画像が少しました傷。そのラインコードのために。
だから私は何をしなければならないのですか、その高さと幅は普通ですか?おかげさまで おかげさまで