位图图像比较
有没有办法查找该方法的实现/源代码? API 需要这个来比较两个图像,因为它不断覆盖原始图像,并且在多次将 imageview 转换为位图之后,图像看起来不再很好了。 http://developer.android.com/reference/android/graphics/Bitmap.html#sameAs(android.graphics.Bitmap)
我正在执行此方法从图像创建位图并设置它再次作为图像视图让用户编辑他的图片。
public static Bitmap getBitmap(ImageView imageView) {
BitmapDrawable mDrawable = (BitmapDrawable) imageView.getDrawable();
Bitmap b = mDrawable.getBitmap();
return b;
}
然而,经过多次保存并从数据库中检索它进行编辑后,图像变成了这样:
对此:
最后是:
所以我需要一种方法来检测图像是否尚未更改,以免重新保存字节该位图的数组到数据库。
Is there a way to look for the implementation/source code of this method? It's in API need this to compare two images because it keeps overwriting the original image and after several times of converting the imageview to a bitmap, the image doesn't look very nice anymore.http://developer.android.com/reference/android/graphics/Bitmap.html#sameAs(android.graphics.Bitmap)
I am doing this method to create a bitmap from the image and setting it again as an imageview to let the user edit his picture.
public static Bitmap getBitmap(ImageView imageView) {
BitmapDrawable mDrawable = (BitmapDrawable) imageView.getDrawable();
Bitmap b = mDrawable.getBitmap();
return b;
}
However, after several times of saving and retrieving it from the database to edit it, the image turns from this:
to this:
and then finally this:
So i need a way of detecting whether the image hasn't been changed for me not to resave the byte array of this bitmap to the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑(基于附加信息)
您可能将图像保存为 JPEG,这是一种有损格式。每次保存都会失去质量。如果您多次加载和保存图像,请使用 PNG 或保留带有图像文本的另一个副本 - 当您需要更新它时,请再次从原始版本开始。
旧答案:
它可能与sameAs无关,并且在其他地方你正在做一些改变图像的事情。
来源位于此处 https://android.googlesource.com。
sameAs
是一个用 C 实现的 JNI 函数,您可以在这里找到它:https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/android/graphics/Bitmap.cpp" rel="nofollow noreferrer"> googlesource.com/platform/frameworks/base/+/master/core/jni/android/graphics/Bitmap.cpp
EDIT (based on additional info)
You are probably saving the image as a JPEG, which is a lossy format. Every time you save you will lose quality. If you are loading and saving the image multiple times, either use PNG or keep another copy with the text of the image with the text -- when you need to update it, start with the original again.
OLD ANSWER:
It probably has nothing to do with sameAs, and somewhere else you are doing something to change the image.
The source is here https://android.googlesource.com.
sameAs
is a JNI function implemented in C, you can find it here:https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/android/graphics/Bitmap.cpp