private void galleryAddPic()
{
Toast.makeText(this,"gelleyAddPic", Toast.LENGTH_SHORT).show();
Toast.makeText(this, mCurrentPhotoPath, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File file = new File(mCurrentPhotoPath);
contentUri = Uri.fromFile(file);
intent.setData(contentUri);
int targetW = imageView.getWidth();
int targetH = imageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);<- 여기서 자꾸 에러가 발생합니다.
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Log.i("scaleFactor", String.valueOf(scaleFactor));
Toast.makeText(this, String.valueOf(scaleFactor), Toast.LENGTH_SHORT).show();
ExifInterface exif = null;
try {
exif = new ExifInterface(mCurrentPhotoPath);
} catch (IOException e) {
e.printStackTrace();
}
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
int exifDegree = exifOrientationToDegrees(exifOrientation);
bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
// imageView.setImageBitmap(bitmap);
imageView.setImageBitmap(rotate(bitmap, exifDegree));
sendBroadcast(intent);
-------------------------------------------------------------------------------------------------------------
W/System.err: java.lang.ArithmeticException: divide by zero 라는 에러가 발생되는데요,
이 에러가 발생할때가 있고 안될때가 있습니다. 왜 이런 현상이 이러나는지 도저히 모르겠습니다 ㅠㅠ
답변 부탁드리겠습니다..!
-------------------------------------------------------------------------------------------------------------
Log 찍어서 확인해본 결과
int targetW = imageView.getWidth();
int targetH = imageView.getHeight();
부분이 둘다 값이 0으로 확인되었습니다. 그런데 왜 그런건지;;..
잘될때가있고 안될때도 있고;;