app: introduce as-is covers
Risks extreme instability since I am no longer in control of format, but some users just want very high-quality covers.
This commit is contained in:
@@ -29,11 +29,13 @@ abstract class CoverFormat {
|
||||
|
||||
companion object {
|
||||
fun jpeg(params: CoverParams): CoverFormat =
|
||||
CoverFormatImpl("jpg", params, Bitmap.CompressFormat.JPEG)
|
||||
CompressingCoverFormat("jpg", params, Bitmap.CompressFormat.JPEG)
|
||||
|
||||
fun asIs(): CoverFormat = AsIsCoverFormat()
|
||||
}
|
||||
}
|
||||
|
||||
private class CoverFormatImpl(
|
||||
private class CompressingCoverFormat(
|
||||
override val extension: String,
|
||||
private val params: CoverParams,
|
||||
private val format: Bitmap.CompressFormat,
|
||||
@@ -63,3 +65,16 @@ private class CoverFormatImpl(
|
||||
return inSampleSize
|
||||
}
|
||||
}
|
||||
|
||||
private class AsIsCoverFormat : CoverFormat() {
|
||||
override val extension: String = "bin"
|
||||
|
||||
override fun transcodeInto(data: ByteArray, output: OutputStream): Boolean {
|
||||
return try {
|
||||
output.write(data)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ private class ExtractStepImpl(
|
||||
val cover =
|
||||
when (val result =
|
||||
covers.create(f, extractedMetadata)) {
|
||||
is CoverResult.Hit<Cover> -> result.cover
|
||||
is CoverResult.Hit -> result.cover
|
||||
else -> null
|
||||
}
|
||||
val rawSong =
|
||||
|
||||
Reference in New Issue
Block a user