gpt4 book ai didi

android - TextureView 中的抗锯齿

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:18:52 32 4
gpt4 key购买 nike

我尝试使用 SurfaceViewTextureView 播放相同的视频,并注意到使用 TextureView 渲染的图像更混叠(不如 SurfaceView 更“流畅”。

这是什么原因?有什么方法可以配置 TextureView 的渲染看起来更好吗?

TextureView 是这样使用的:

    TextureView textureView = new TextureView(this);
textureView.setSurfaceTextureListener(new SurfaceTextureListener() {

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
Log.i("test", "onSurfaceTextureAvailable()");
MediaPlayer player = MediaPlayer.create(TestActivity.this, Uri.parse(VIDEO_URL));
Surface surface = new Surface(surfaceTexture);
player.setSurface(surface);
player.start();
}

@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
Log.i("test", "onSurfaceTextureUpdated()");
}

@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
Log.i("test", "onSurfaceTextureSizeChanged()");
}

@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Log.i("test", "onSurfaceTextureDestroyed()");
return false;
}
});
setContentView(textureView);

对于 SurfaceView:

    SurfaceView surfaceView = new SurfaceView(this);
surfaceView.getHolder().addCallback(new Callback() {

@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.i("test", "surfaceCreated()");
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.i("test", "surfaceDestroyed()");
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.i("test", "surfaceChanged()");
MediaPlayer player = MediaPlayer.create(TestActivity.this, Uri.parse(VIDEO_URL));
player.setSurface(holder.getSurface());
player.start();
}
});
setContentView(surfaceView);

最佳答案

好吧,似乎在 TextureView 上应用缩放比例(不是 1)可以实现我正在寻找的“平滑”效果。

textureView.setScaleX(1.00001f);

这听起来像是一个奇怪的技巧……但它确实有效。挖掘在改变渲染方面的缩放中所做的事情会很有趣......

关于android - TextureView 中的抗锯齿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12474260/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com