मुझे बिटमैप मिला है ... और यदि बिटमैप की ऊंचाई maxHeight से अधिक है, या चौड़ाई maxWidth से अधिक है, तो मैं आनुपातिक रूप से छवि का आकार बदलना चाहता हूं ताकि यह maxWidth X में फिट हो अधिकतम ऊँचाई। यहाँ मैं क्या कोशिश कर रहा हूँ है:आनुपातिक रूप से बिटमैप का आकार बदलें
BitmapDrawable bmp = new BitmapDrawable(getResources(), PHOTO_PATH);
int width = bmp.getIntrinsicWidth();
int height = bmp.getIntrinsicHeight();
float ratio = (float)width/(float)height;
float scaleWidth = width;
float scaleHeight = height;
if((float)mMaxWidth/(float)mMaxHeight > ratio) {
scaleWidth = (float)mMaxHeight * ratio;
}
else {
scaleHeight = (float)mMaxWidth/ratio;
}
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap out = Bitmap.createBitmap(bmp.getBitmap(),
0, 0, width, height, matrix, true);
try {
out.compress(Bitmap.CompressFormat.JPEG, 100,
new FileOutputStream(PHOTO_PATH));
}
catch(FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
मैं निम्न अपवाद प्राप्त करें:
java.lang.IllegalArgumentException: bitmap size exceeds 32bits
क्या मैं गलत यहाँ कर रहा हूँ?
अतीत आप कर सकते हैं को सही कोड यहाँ? मुझे एक ही अपवाद मिल रहा है – Mahesh