回答編集履歴

2

解説追加

2017/10/02 05:13

投稿

masaya_ohashi
masaya_ohashi

スコア9206

test CHANGED
@@ -25,3 +25,21 @@
25
25
  canvas.drawBitmap(myBitmap, flipHorizontalMatrix, myPaint);
26
26
 
27
27
  ```
28
+
29
+ X方向のscaleを-1することで左右反転した画像を、画像幅分右に動かして元の位置に戻しています。
30
+
31
+
32
+
33
+ ```
34
+
35
+ □■
36
+
37
+ ↓ setScale(-1,1)
38
+
39
+ ■□ このままだと左にずれてる
40
+
41
+ ↓ postTranslate(myBitmap.getWidth(),0)
42
+
43
+ ■□ 反転した画像を元の位置に戻す作業
44
+
45
+ ```

1

SurfaceViewでのフリップ方法の追記

2017/10/02 05:13

投稿

masaya_ohashi
masaya_ohashi

スコア9206

test CHANGED
@@ -1,3 +1,27 @@
1
1
  ただ反転させるならImageViewのscaleXやscaleYに-1を入れるとできます。
2
2
 
3
3
  [https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically](https://stackoverflow.com/questions/29061523/android-flip-imageview-vertically)
4
+
5
+
6
+
7
+ ### 追記
8
+
9
+ SurfaceViewを使うとなればCanvas#drawBitmapとかですかね。
10
+
11
+ 左右反転や上下反転は「flip」で検索すると情報が出てきやすいです。これは「android canvas bitmap flip」で検索したときに出てきた情報です。
12
+
13
+ [https://stackoverflow.com/questions/7774618/flipping-a-bitmap-in-android-help](https://stackoverflow.com/questions/7774618/flipping-a-bitmap-in-android-help)
14
+
15
+ ```Java
16
+
17
+ Matrix flipHorizontalMatrix = new Matrix();
18
+
19
+ flipHorizontalMatrix.setScale(-1,1);
20
+
21
+ flipHorizontalMatrix.postTranslate(myBitmap.getWidth(),0);
22
+
23
+
24
+
25
+ canvas.drawBitmap(myBitmap, flipHorizontalMatrix, myPaint);
26
+
27
+ ```