我无法使用 MS Paint 在 sdk 上将位图保存为 jpg 文件打开
我将位图保存为 jpg 文件。源代码是:
imageView = new ImageView(this);
bitmap = Bitmap.createBitmap(d.getWidth() ,d.getHeight() , Bitmap.Config.ARGB_8888);
canvas = new Canvas (bitmap);
iv.setDrawingCacheEnabled(true);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/mnt/sdcard/mrun.jpg")));
我在模拟器上测试它。文件已保存,大小约为 150 Kb。但是,如果我想使用 MS Paint 等任何程序打开它,我会收到错误消息。我想念什么?谢谢。 评论:我尝试写以下行而不是最后一个原始数据:
iv.getDrawingCache().compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/mnt/sdcard/arun.jpg")));
相同的结果。
I save bitmap as jpg file. The source code is:
imageView = new ImageView(this);
bitmap = Bitmap.createBitmap(d.getWidth() ,d.getHeight() , Bitmap.Config.ARGB_8888);
canvas = new Canvas (bitmap);
iv.setDrawingCacheEnabled(true);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/mnt/sdcard/mrun.jpg")));
I test it on emulator. The file is saved and it has size ~150 Kb. But if I want to open it with any program as MS Paint, I receive the error message. What do I miss? Thanks.
COMMENT: I tried to write instead of the last raw the follow row:
iv.getDrawingCache().compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/mnt/sdcard/arun.jpg")));
Same result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 MS Paint 不能与 Alpha 通道一起使用。因此,它无法读取带有 alpha 通道的 jpg。只是一个想法。
尝试使用一些普通的图形编辑器打开。例如,金普。它是免费的。
I think, that MS Paint can't work with Alpha channel. So, it can't read jpg with alpha channel. Just a thought.
try to open by some normal graphic editor. Gimp, for example. It is free.
最可能的原因:该文件可能未正确写入,即未采用正确的 jpeg 格式。虽然代码看起来没问题。
这有效。
The most probable reason: The file might not have been written properly, ie, not in a proper jpeg format. Although the code seems to be fine.
This works.