Android – TextureView getbitmap() ignores settransform

I am using TextureView for camerapreview. Due to the difference between display ratio and preview ratio, I use textureview.settransform (matrix) in onsurfacetextureavailable(). When I need a screenshot of TextureView, I use TextureView. Getbitmap(), but in some smartphone models, getbitmap() ignores the scaling of preview. Why?

resolvent:

I found the same problem when I needed to post process the camera preview before display

It seems that the original camera capture is what appears in getbitmap (), not the converted view of the final display

I solved the following problem. It only applies the same transformation after pulling out bitmap:

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 );
@H_404_15@

我注意到Bitmap没有像在原始视图中那样被裁剪.在我的例子中,TextureView已经裁剪了图像的顶部和底部,而Bitmap仍然是全尺寸的.基本上,认情况下,看起来TextureView使用等效的“centerCrop”来显示原始源.我将相应的ImageView设置为使用android:scaleType =“centerCrop”并且视图具有相同的方面.

当然,这意味着我正在处理更多我真正需要的图像,但是我还没有弄清楚如何在处理之前完全裁剪出TextureView正在做的事情.

总结

以上是编程之家为你收集整理的android – TextureView getBitmap()忽略setTransform全部内容,希望文章能够帮你解决android – TextureView getBitmap()忽略setTransform所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>