From 380414670b541d41216fde770b60a442bc72f642 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 8 Aug 2012 18:47:33 +0800 Subject: Rotate the texture in building PhotoFallbackEffect bug: 6525127 Change-Id: Iba348450b62190a1a2149cf0d7f20f19625cb6cf --- src/com/android/gallery3d/ui/PhotoView.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index ec042da23..c9fefca28 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -1745,9 +1745,24 @@ public class PhotoView extends GLView { if (!Rect.intersects(fullRect, rect)) continue; rect.offset(location.left, location.top); - RawTexture texture = new RawTexture(sc.getWidth(), sc.getHeight(), true); - canvas.beginRenderTarget(texture); - sc.draw(canvas, 0, 0, sc.getWidth(), sc.getHeight()); + int width = sc.getWidth(); + int height = sc.getHeight(); + + int rotation = mModel.getImageRotation(i); + RawTexture texture; + if ((rotation % 180) == 0) { + texture = new RawTexture(width, height, true); + canvas.beginRenderTarget(texture); + canvas.translate(width / 2f, height / 2f); + } else { + texture = new RawTexture(height, width, true); + canvas.beginRenderTarget(texture); + canvas.translate(height / 2f, width / 2f); + } + + canvas.rotate(rotation, 0, 0, 1); + canvas.translate(-width / 2f, -height / 2f); + sc.draw(canvas, 0, 0, width, height); canvas.endRenderTarget(); effect.addEntry(item.getPath(), rect, texture); } -- cgit v1.2.3