This page (revision-1) was last changed on 20-Apr-2024 11:53 by Hiroaki Tateshita

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
20-Apr-2024 11:53 1 KB Hiroaki Tateshita

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 1 added 29 lines
[{PageViewPlugin}]
[Android Programming Tips]
!!!Abstract
!!!Topic
*Camera2
|Androidでちゃんとカメラが扱えるようになりたいが、結構奥が深い。camera2を使いたいが、サンプルとしてこれ[4]がシンプル。このサンプルで、TextureView.getSurfaceTexture()を呼ぶとき、NullPointerExceptionが起きやすい。Availableになってから呼ばないといけないので、呼び出し元をListenerのonSurfaceTextureAvailable()から呼ぶ必要があることに注意[5]。
*ViewからBitmap?
|TextureViewだったら
{{{
mTextureView.getBitmap();
}}}
|で、ただのViewだったら、
{{{
arView.getDrawingCache(false);
}}}
|でBitmapが取れる。
*Bitmapを重ねるには
|Canvasクラスをつかって重ね書きしましょう。
{{{
Bitmap offBitmap = Bitmap.createBitmap(cameraMap.getWidth(), cameraMap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvasForCombine = new Canvas(offBitmap);
canvasForCombine.drawBitmap(cameraMap, null, new Rect(0, 0, cameraMap.getWidth(), cameraMap.getHeight()), null);
canvasForCombine.drawBitmap(overlayMap, null, new Rect(0, 0, cameraMap.getWidth(), cameraMap.getHeight()), null);
}}}
!!!Reference
#[#4]株式会社BELLSOFT, 2018年4月13日, Androidアプリにおける最小限のカメラ機能の実装, [https://bellsoft.jp/blog/system/detail_538]
#[#5]TextureView, [https://developer.android.com/reference/android/view/TextureView]