Drop support for reencode images

This commit is contained in:
len
2016-10-23 13:22:14 +02:00
parent c1ac47e1ce
commit d7b8015df7
11 changed files with 5 additions and 45 deletions

View File

@@ -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)
}
}