joshkendrick
joshkendrick

Reputation: 3547

Android rotate bitmap without making a copy

Is there a way to rotate a bitmap without making a copy of it? Or maybe the imageview that's holding the bitmap? Right now I've got something similar to:

Bitmap bm = BitmapFactory.decodeFile(...
// get the orientation
Matrix m = new Matrix
m.postRotate(orientation)
Bitmap new = Bitmap.createFromBitmap(bm, ..., m);

Upvotes: 4

Views: 3276

Answers (1)

trumpetlicks
trumpetlicks

Reputation: 7085

There really algorithmically isnt an EASY way of performing this rotation without a completely separate new place to put the rotated copy, then deleting the current (non-rotated) copy. I can think of a potential algorithm where you would essentially have to have one pixel' worth of memory but I would have to spend more time figuring out the actual algorithm.

Also look at this StackOverflow Link: Algorithm to rotate an image 90 degrees in place? (No extra memory)

Upvotes: 1

Related Questions