Bitmap
は高さためにロードできないときはい、それが起こると、画像の幅は、2048*2048
である。カメラで撮影した画像は通常サイズが大きいので、画像のサイズを変更することをお勧めします。以下は
サイズが大きな場合クロップ画像の一例であり、などの画像比
public class InputImageCompressor extends Activity{
public static void compressInputImage(Uri inputImageData, Context context, ImageView newIV)
{
Bitmap bitmap;
//Uri inputImageData = data.getData();
try
{
Bitmap bitmapInputImage = MediaStore.Images.Media.getBitmap(context.getContentResolver(), inputImageData);
if (bitmapInputImage.getWidth() > 2048 && bitmapInputImage.getHeight() > 2048)
{
bitmap = Bitmap.createScaledBitmap(bitmapInputImage, 1024, 1280, true);
newIV.setImageBitmap(bitmap);
}
else if (bitmapInputImage.getWidth() > 2048 && bitmapInputImage.getHeight() < 2048)
{
bitmap = Bitmap.createScaledBitmap(bitmapInputImage, 1920, 1200, true);
newIV.setImageBitmap(bitmap);
}
else if (bitmapInputImage.getWidth() < 2048 && bitmapInputImage.getHeight() > 2048)
{
bitmap = Bitmap.createScaledBitmap(bitmapInputImage, 1024, 1280, true);
newIV.setImageBitmap(bitmap);
}
else if (bitmapInputImage.getWidth() < 2048 && bitmapInputImage.getHeight() < 2048)
{
bitmap = Bitmap.createScaledBitmap(bitmapInputImage, bitmapInputImage.getWidth(), bitmapInputImage.getHeight(), true);
newIV.setImageBitmap(bitmap);
}
} catch (Exception e)
{
Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
}
}
}
使用これはあなたのonActivityResult
での世話をしない:私はしようとした
InputImageCompressor.compressInputImage(data, activity_context, imageView_to_place_image(imageview));
ガレリー(ダウンロードフォルダ)から3840 * 2160の画像を選択してください。そのうまくいっています.... – pankaj
しかし、カメラから来る画像を圧縮しようとすると動作します – W4R10CK