problem description
Android6.0 and 7.0load a jpg image, convert it to bitmap, and save it locally. Compare the binary of the two local images with UE, and the results are inconsistent.
the environmental background of the problems and what methods you have tried
(1) the bitmapFactory results of the system are also the same, inconsistent,
(2) Glide is not good
(3) there is a strange phenomenon, 4.4,5.0,6.0,8.1 are the same, 7.0,7.1,8.0 results are the same.
related codes
Picasso.get()
.load(R.drawable.web_z)
.config(Bitmap.Config.ARGB_8888)
.resize(500,400)
.transform(object : Transformation {
override fun key(): String = "test"
override fun transform(source: Bitmap): Bitmap {
FileUtilTest.save(source, "picasso")
return source
}
}).into(mImageView)
//bitmap
object FileUtilTest {
fun save(bitmap: Bitmap, flag: String) {
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED)
// SDcard
{ // SDCard
val sdCardDir = Environment.getExternalStorageDirectory().toString() + "/CoolImage/"
val dirFile = File(sdCardDir) //
if (!dirFile.exists()) { //
dirFile.mkdirs()
} //
val file = File(sdCardDir, flag + "_" + System.currentTimeMillis() + ".png")// SDcard,
var out: FileOutputStream? = null
try {
out = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out)
out.flush()
Log.d("TAG", "_____________sd__________________________")
} catch (e: Exception) {
e.printStackTrace()
} finally {
if (out != null) {
try {
out.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
}
Log.d("TAG", "" + Environment.getExternalStorageDirectory() + "/CoolImage/" + "")
}
}
}
how to solve this problem?