我正在尝试检索bitmap
并保存到PC上的本地磁盘。
结果我得到了一个无法读取的jpeg文件(95字节)。
源:
Application application = new MyApplication();
Bitmap bitmap = BitmapFactory.decodeResource(application.getResources(), drawableId);
File outputFile = new File("D:\\OutputFile.jpg");
OutputStream os = new FileOutputStream(outputFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os);
IoUtils.closeSilently(os); //close stream
P.S。我知道我无法从bitmap
获得drawable
。但我不知道为什么......
答案 0 :(得分:0)
因此,请尝试将Bitmap类型图像转换为Drawable
Drawable d = new BitmapDrawable(getResources(),bitmap);