我使用Glide从相册加载图片到
我的问题是,当
这是我用于通过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
.
*/
}
}) ;
我想了一秒钟,可能是GLSurfaceView
的问题,我猜可能与非常小的宽度有关。但是看起来它在图像被调整大小之前渲染得很完美。
我的代码有什么问题吗? 我真的很感谢任何建议。