回答編集履歴
2
解説追加
answer
CHANGED
|
@@ -11,4 +11,13 @@
|
|
|
11
11
|
flipHorizontalMatrix.postTranslate(myBitmap.getWidth(),0);
|
|
12
12
|
|
|
13
13
|
canvas.drawBitmap(myBitmap, flipHorizontalMatrix, myPaint);
|
|
14
|
+
```
|
|
15
|
+
X方向のscaleを-1することで左右反転した画像を、画像幅分右に動かして元の位置に戻しています。
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
□■
|
|
19
|
+
↓ setScale(-1,1)
|
|
20
|
+
■□ このままだと左にずれてる
|
|
21
|
+
↓ postTranslate(myBitmap.getWidth(),0)
|
|
22
|
+
■□ 反転した画像を元の位置に戻す作業
|
|
14
23
|
```
|
1
SurfaceViewでのフリップ方法の追記
answer
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
ただ反転させるならImageViewのscaleXやscaleYに-1を入れるとできます。
|
|
2
|
-
[https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically](https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically)
|
|
2
|
+
[https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically](https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically)
|
|
3
|
+
|
|
4
|
+
### 追記
|
|
5
|
+
SurfaceViewを使うとなればCanvas#drawBitmapとかですかね。
|
|
6
|
+
左右反転や上下反転は「flip」で検索すると情報が出てきやすいです。これは「android canvas bitmap flip」で検索したときに出てきた情報です。
|
|
7
|
+
[https://stackoverflow.com/questions/7774618/flipping-a-bitmap-in-android-help](https://stackoverflow.com/questions/7774618/flipping-a-bitmap-in-android-help)
|
|
8
|
+
```Java
|
|
9
|
+
Matrix flipHorizontalMatrix = new Matrix();
|
|
10
|
+
flipHorizontalMatrix.setScale(-1,1);
|
|
11
|
+
flipHorizontalMatrix.postTranslate(myBitmap.getWidth(),0);
|
|
12
|
+
|
|
13
|
+
canvas.drawBitmap(myBitmap, flipHorizontalMatrix, myPaint);
|
|
14
|
+
```
|