如何保存表面纹理位图 [英] How to save SurfaceTexture as bitmap

查看:602
本文介绍了如何保存表面纹理位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我去codeA视频表面我要救我想为位图/ JPEG文件的帧。我不想在屏幕上绘制,只是想保存的表面纹理作为图像文件中的内容。

When I decode a video to a surface I want to save the frames i want as bitmap/jpeg files. I don't want to draw on the screen and just want to save the content of the SurfaceTexture as an image file.

推荐答案

您已经呈现质感。

如果它是一个正常的质感,而你正在使用GLES 2或更高版本,你可以将其连接到一个FBO,然后直接从中读出。 A 表面纹理是由一个的外部纹理,并可能是该GL驱动程序不支持全套的操作上的格式,所以你不能这样做。你需要使它和读取结果。

If it were a normal texture, and you were using GLES 2 or later, you could attach it to an FBO and read directly from that. A SurfaceTexture is backed by an "external texture", and might be in a format that the GL driver doesn't support a full set of operations on, so you can't do that. You need to render it, and read the result.

FWIW,你去拯救框架可以有显著影响性能的方式。一个完整的例子演示了使用 MediaExtractor 媒体codeC glReadPixels() 和PNG文件的创建,现在上bigflake( ExtractMpegFramesTest

FWIW, the way you go about saving the frame can have a significant performance impact. A full example demonstrating the use of MediaExtractor, MediaCodec, glReadPixels(), and PNG file creation is now up on bigflake (ExtractMpegFramesTest).

这篇关于如何保存表面纹理位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆