我正在将一个位图加载到ImageView中,并看到此错误.我收集此限制与OpenGL硬件纹理(2048x2048)的大小限制有关.我需要加载的图像是大约4,000像素高的捏缩图像.
我试过关闭清单中的硬件加速,但没有快乐.
<application
android:hardwareAccelerated="false"
....
>
Run Code Online (Sandbox Code Playgroud)
是否可以将大于2048像素的图像加载到ImageView中?
我正在开发一个应用程序,我需要从中选择一个图像sd card并在图像视图中显示它.现在我希望用户通过单击按钮减小/增加其宽度,然后将其保存回SD卡.
我已经完成了图像拾取并在ui上显示它.但无法找到如何调整它的大小.任何人都可以建议我如何实现它.
我正在使用位图.当代码运行时,它显示内存不足错误.如何避免错误.我的代码如下.提前致谢.
Bitmap myBitmap = Image.decodeSampledBitmapFromUri(path, 250, 500);
img_cook[index].setImageBitmap(myBitmap);
public static Bitmap decodeSampledBitmapFromUr(String path, int reqWidth,
int reqHeight) {
Bitmap bm = null;
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
options.inJustDecodeBounds = false;
bm = BitmapFactory.decodeFile(path, options);
return bm;
}
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) …Run Code Online (Sandbox Code Playgroud) 我的android应用程序处理非常大的Bitmaps.因此,我在图像视图中关闭了硬件加速功能.但是,有些用户已将Developer-Option的"强制GPU加速"设置为开启状态.这会导致错误"位图太大而无法上传到纹理中".如果我使用isHardwareAccelerated()检查视图,它总是返回false.
有没有办法捕获OpenGL-Error'Bitmap太大而无法上传到纹理'?