I'm getting error java.lang.ArithmeticException: divide by zero
when compress image from pick gallery. this Is my code:
public String compressImage(String filePath, String outputFilename) {
Bitmap scaledBitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bmp = BitmapFactory.decodeFile(filePath, options);
int actualHeight = options.outHeight;
int actualWidth = options.outWidth;
Log.i("INFO", "ActualHeight Input: " + actualHeight);
Log.i("INFO", "ActualWidth Input: " + actualWidth);
float maxHeight = 816.0f;
float maxWidth = 612.0f;
float imgRatio = actualWidth / actualHeight;
float maxRatio = maxWidth / maxHeight;
............
return outputFilename;
}
the error get in lin : float imgRatio = actualWidth / actualHeight;
so how to fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…