Q:

Bitmap out of range error

I'm resizing an array of Bitmaps to a certain percentage of screen (So looks the same on all devices). Some of the bitmaps are sprites with + 256kb in size (explosions etc). 
Obviously the VM is running out of memory once the bitmaps are converted twice, the bitmaps only convert at the beginning of the android application but it's still giving the error.
Can anyone tell me, is there a better, faster, more effcient way to return this peice of code as a bitmap. 
Just out of curiosity are bitmap values passed by reference? (As in does the object parameter use the same line of memory for the same object?).
Anyhow's here is z code:
public Bitmap ResizeBitmap(Bitmap bitmap, float s_percentage, int frames, int viewport_width, int viewport_height)
{
    float percentage = s_percentage / 100.0f;

    float scale = viewport_width / 100 * percentage;
    if(viewport_width < viewport_height)
    {
        scale = viewport_height / 100 * percentage;
    }

    int newWidth = (int) (bitmap.getWidth() * scale);
    int newHeight = (int) (bitmap.getHeight() * scale);

    if(newWidth <= 0 || newHeight <= 0)
    { 
        // Extra check, for invalid width/height
        Log.e("Function List, Resize Bitmap", "invalid dimension ("+newWidth+"x"+newHeight+")");
        return bitmap;
    }

    //Round up to closet factor of total frames
    int rW = (newWidth/frames)+1;
    newWidth = rW*frames;

    Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);

    return newBitmap;
}

A:

To be in VM budget try to scale down your Bitmap like this.
BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile( filename, options );
        options.inJustDecodeBounds = false;
        options.inSampleSize = 4; 

        bitmap = BitmapFactory.decodeFile( filename, options );
        if ( bitmap != null ) {
            bitmap = Bitmap.createScaledBitmap( bitmap, width, height, false );
        }

//Adjust SampleSize to values like 2, 4, 8 etc 

