我正在使用自定义 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。
问题:
一个。无论设备屏幕尺寸如何,都可以获得合适尺寸的图像吗?
湾。是否可以直接对自定义 ImageView 中使用的图像进行图像处理?
感谢期待!
有什么想法吗?