mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 05:27:28 +01:00
Drop support for reencode images
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import okio.BufferedSource
|
||||
import okio.Okio
|
||||
import java.io.File
|
||||
@@ -39,24 +37,3 @@ fun BufferedSource.saveTo(stream: OutputStream) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given source to an output stream and closes both resources.
|
||||
* The source is expected to be an image, and it may reencode the image.
|
||||
*
|
||||
* @param stream the stream where the source is copied.
|
||||
* @param reencode whether to reencode the image or not.
|
||||
*/
|
||||
fun BufferedSource.saveImageTo(stream: OutputStream, reencode: Boolean = false) {
|
||||
if (reencode) {
|
||||
use {
|
||||
val bitmap = BitmapFactory.decodeStream(it.inputStream())
|
||||
stream.use {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, it)
|
||||
}
|
||||
bitmap.recycle()
|
||||
}
|
||||
} else {
|
||||
saveTo(stream)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user