由於顯示比率和預覽比率之間的差異,我使用TextureView for CameraPreview,我使用onSurfaceTextureAvailable()中的textureView.setTransform(matrix)來縮放預覽。當我需要紋理視圖的屏幕截圖時,我使用了textureView.getBitmap(),但在某些智能手機模型中,getBitmap()忽略預覽的縮放比例。爲什麼會發生?textureview getbitmap忽略setTransform
2
A
回答
2
當我需要在顯示相機預覽之前進行後期處理時,我發現了同樣的問題。
它看起來像原始相機捕獲是什麼出現在getBitmap()而不是最終被顯示的轉換視圖。
我工作圍繞這一問題與以下,這只是應用相同的變換位圖被拉出來後:
TextureView textureView = (TextureView) findViewById(R.id.texture);
Matrix m = new Matrix();
// Do matrix creation here.
textureView.setTransform(m);
// When you need to get the Bitmap
Bitmap bitmap = textureView.getBitmap();
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), textureView.getTransform(null), true);
我也注意到,位圖不被裁剪像它可能是在原視圖。在我的情況下,TextureView已經裁剪了圖像的頂部和底部,而位圖仍然是全尺寸的。基本上,它看起來像TextureView默認使用等價的「centerCrop」顯示原始源。我將相應的ImageView設置爲使用android:scaleType="centerCrop"
,並且視圖具有相同的方面。
當然,這意味着我正在處理更多我真正需要的圖像,但我還沒有弄清楚如何在處理之前精確地顯示TextureView正在做什麼。
相關問題
- 1. TextureView getBitmap java.lang.IllegalStateException
- 2. TextureView getBitmap()在角落創建小窗口反射
- 3. Android TextureView:調用getBitmap時顯示灰色框架的視頻
- 4. CBitmap :: GetBitmap失敗
- 5. IS忽略被忽略
- 6. bin - 忽略或不忽略
- 7. 忽略映射忽略
- 8. Automapper忽略屬性忽略
- 9. svn:忽略不忽略xcuserdata
- 10. SVN忽略被忽略
- 11. box2d,setTransform和碰撞
- 12. 忽略
- 13. 忽略
- 14. 忽略
- 15. 忽略
- 16. 忽略
- 17. G ++忽略忽略_Pragma診斷
- 18. vagrant忽略Vagrantfile安裝點忽略
- 19. 忽略未被忽略的文件
- 20. java webstart忽略System.getProperties()或Syste.setProperties()被忽略
- 21. 搖籃忽略守護忽略標誌
- 22. .babelrc忽略場似乎被忽略
- 23. 爲什麼'svn忽略'不能忽略?
- 24. mysqldump忽略表不會忽略視圖
- 25. svn:忽略排除文件被忽略
- 26. 忽略SVN忽略...可能嗎?
- 27. Direct3D Sprite-> SetTransform用法?
- 28. Android中的settransform()方法
- 29. 從SQLite到ListView的getBitmap
- 30. setTransform階段方法,Easeljs