Bitmap size exceed VM budget
<p>I have read those posts on this issue but my case is abit different as I am NOT DISPLAYING the bitmap but just post-processing the image from raw data.
First, I call <code>ImageProcessing.rgbToBitmap(data,width, height);</code> which will return a Bitmap object. Then I perform these 3 functions SEPARATELY.</p>

<ol>
<li>Rotate Bitmap</li>
<li>Add a watermark overlay to Bitmap</li>
<li>Add date at lower right hand corner of Bitmap</li>
</ol>

<p>All 3 methods called will create an return a Bitmap object which probably causes the crash as I am trying to save an image every 1000ms! Sometimes the images saved are distorted probably due to the memory error.</p>

<p>I am posting my codes below and any advices are greatly appreciated. I do not want to compromise on the quality on the image taken though. (Need to preserve the resolution)</p>

<pre><code>public static Bitmap addWatermark(Resources res, Bitmap source) {
        int w, h;
        Canvas c;
        Paint paint;
        Bitmap bmp, watermark;

        Matrix matrix;
        float scale;
        RectF r;

        w = source.getWidth();
        h = source.getHeight();

        // Create the new bitmap
        bmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG
                | Paint.FILTER_BITMAP_FLAG);

        // Copy the original bitmap into the new one
        c = new Canvas(bmp);
        c.drawBitmap(source, 0, 0, paint);

        // Load the watermark
        watermark = BitmapFactory.decodeResource(res, R.drawable.watermark);
        // Scale the watermark to be approximately 10% of the source image
        // height
        scale = (float) (((float) h * 0.80) / (float) watermark.getHeight());

        // Create the matrix
        matrix = new Matrix();
        matrix.postScale(scale, scale);
        // Determine the post-scaled size of the watermark
        r = new RectF(0, 0, watermark.getWidth(), watermark.getHeight());
        matrix.mapRect(r);
        // Center watermark
        matrix.postTranslate((w - r.width()) / 2, (h - r.height()) / 2);

        // Draw the watermark
        c.drawBitmap(watermark, matrix, paint);
        // Free up the bitmap memory
        watermark.recycle();

        return bmp;
    }

public static Bitmap addDate(Bitmap src, String date) {
        int w = src.getWidth();
        int h = src.getHeight();
        //Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());
        Bitmap result = src;
        Canvas canvas = new Canvas(result);
        canvas.drawBitmap(src, 0, 0, null);

        Paint paint = new Paint(); 
        paint.setColor(Color.rgb(255, 185, 15)); 
        paint.setTextSize(20);
        paint.setAntiAlias(true);
        canvas.drawText(date, w - 200, h - 20, paint);

        return result;
    }
public static Bitmap rotate(Bitmap src, int rotation) {

        int width = src.getWidth();
        int height = src.getHeight();

        // create a matrix for the manipulation
        Matrix matrix = new Matrix();
        // rotate the Bitmap
        matrix.postRotate(rotation);

        // recreate the new Bitmap, swap width and height and apply
        // transform
        Bitmap rotatedBitmap = Bitmap.createBitmap(src, 0, 0, width, height,
                matrix, true);
        return rotatedBitmap;

    }
</code></pre>
