【发布时间】:2011-05-20 14:14:10
【问题描述】:
我正在使用自定义 ImageView。在它的 onDraw 中,我使用画布做一些处理,就像画线,基于用户触摸的位图。
为了在用户想要保存图像时保存生成的快照,我们使用了 drawingCache
imageView.setDrawingCacheEnabled(true;
Bitmap.createBitmap(imageView.getDrawingCache(), 0, 0,
imageView.getHeight(), imageView.getWidth(),
matrix, true).compress(CompressFormat.JPEG, 95,
new FileOutputStream(file));
当然,当用户按下保存时,我可以使用它来获取实际图像,但图像不包含对 imageView 所做的任何处理。
Bitmap bmp = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
Bitmap.createBitmap(bmp, 0, 0,
bmp.getWidth(), bmp.getHeight(),
matrix, true).compress(CompressFormat.JPEG, 95,
new FileOutputStream(file));
问题: 保存的图像大小是全屏的 imageView 的大小,但取决于设备。对于较小屏幕尺寸的手机,它会降至 240 X 320。
问题:
一个。无论设备屏幕尺寸如何,是否可以获得合适尺寸的图像?
b.是否可以直接对 Custom ImageView 中使用的 Image 进行图像处理?
感谢期待!
有什么想法吗?
【问题讨论】: