Proportionally resize a bitmap
<p>I've got a bitmap... and if the bitmap's height is greater than maxHeight, or the width is greater than maxWidth, I'd like to proportionally resize the image so that it fits in maxWidth X maxHeight.  Here's what I'm trying:</p>

<pre><code>    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 &gt; 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();
    }
</code></pre>

<p>I get the following exception:</p>

<p><code>java.lang.IllegalArgumentException: bitmap size exceeds 32bits</code></p>

<p>What am I doing wrong here?</p>
