0
this 링크에 따라 이미지 크기를 조정합니다.
이미지 크기가 3264x2448이고 샘플 크기를 계산 한 후 이제 24이지만 이미지가 90도 (왼쪽)로 회전합니다.
폭이 높이보다 큰 경우가 발생합니다.
나는 갇혔다. 해결할 수 없습니다. 이미지 크기 조정 문제
I am using accroding to http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
public static String getCompressedImagePath(String orgImagePath,
String storeImagePath) {
if (orgImagePath == null) {
return null;
}
Bitmap bitmap = decodeSampledBitmapFromResource(orgImagePath, 100, 100);
String absolutePath = "";
FileOutputStream fos = null;
try {
fos = new FileOutputStream(storeImagePath);
bitmap.compress(getCompressionFormatType(orgImagePath),
IMAGE_COMPRESS_FACTOR, fos);
fos.flush();
absolutePath = storeImagePath;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
fos = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return absolutePath;
}
public static Bitmap decodeSampledBitmapFromResource(String orgImagePath,
int reqWidth, int reqHeight) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(orgImagePath, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
reqHeight);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(orgImagePath, options);
}
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
if (width > height) {
inSampleSize = Math.round((float) height/(float) reqHeight);
} else {
inSampleSize = Math.round((float) width/(float) reqWidth);
}
}
return inSampleSize;
}
그리고 decodeSampledBitmapFromResource 방법
링크에서 복사 intoimageview으로 압축 된 이미지를 설정하고있다.
코드를 게시하시기 바랍니다 누락 밖의 무엇을 찾아이 응용 프로그램 &을 실행 당신도 사용하고 있습니다. – noob
그리고 일부 샘플 이미지. –