我正在使用Glide将图片加载到图库中GLSurfaceView.但是,当我尝试使用时调整图像大小时override(width, height),它不会这样做.因此,我补充说fitCenter(),这似乎是获得所需大小的关键.
我的问题是当Bitmap调整大小时结果很奇怪!除了宽度值较小的图像外,一切都很好.附图说明了使用和不使用之间的区别fitCenter().
这是我用于通过Glide加载的代码
Glide.with(this)
.load(imageUri)
.asBitmap()
.override(newWidth, newHeight)
.fitCenter()
.atMost()
.into(new SimpleTarget<Bitmap>(newWidth, newHeight) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
Log.e(TAG, "Loaded Bitmap Size :" + resource.getWidth() + "x" + resource.getHeight());
/*
.
. Initialize GLSurfaceView with Bitmap resource
.
*/
}
}) ;
Run Code Online (Sandbox Code Playgroud)
我想了一下它可能是一个GLSurfaceView问题,我想到了一个与非常小的宽度相关的东西.但它看起来完美渲染,直到调整图像大小.
我的代码有什么问题吗?我真的很感激任何建议.
EDIT [解决]:
它看起来像使用时出现问题fitCenter()与GLSurfaceView用Bitmap具有宽度或高度为奇数.我通过添加以下自定义转换来解决此问题Glide.
@Override
protected Bitmap transform(BitmapPool pool, Bitmap …Run Code Online (Sandbox Code Playgroud)