0

I'm trying to set a bitmap's rotation using a matrix but I am having some trouble here.

Does anyone know how to rotate a bitmap?? I am so confused why this would give out of memory errors. My code is plain and simple:

thisRotation = Math.toDegrees(Math.atan2(
            (fingery1 - thisRectf.centerY()),
            (fingerx1 - thisRectf.centerX()))));
matrix.setRotate(thisRotation, thisRectf.centerX(),
            thisRectf.centerY());
Bitmap.createBitmap(thisBitmap, 0, 0, thisBitmap.getWidth(), 
                         thisBitmap.getHeight(), matrix, true);

I have used google and apparently this is not an easy fix? My image is very small (9 kb) and i've tried lowering it to 900 bytes but it still causes gc.

stegrd
  • 25
  • 6
  • 2
    Unless you're getting actual OutOfMemoryException or having performance issues due to the gc I wouldn't worry about it. – Gabe Sechan Jul 02 '14 at 09:44
  • Look at my ans here : http://stackoverflow.com/questions/24128346/getting-rotation-from-exifinterface-always-returns-0/24219714#24219714 – Haresh Chhelana Jul 02 '14 at 09:49
  • Please check if http://stackoverflow.com/questions/11260761/is-gc-for-alloc-more-serious-when-investigating-memory-usage relates or answers your question. – joecks Jul 02 '14 at 09:51

1 Answers1

0

I was using a custom view, and in my onDraw method, I used

canvas.drawBitmap(bitmap, srcRectf, dstRectf, paint);

to draw my bitmap, but I should have been using

canvas.drawBitmap(bitmap, matrix, paint);
stegrd
  • 25
  • 6