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:
Alexander Capehart
2025-03-03 13:09:26 -07:00
parent a7000bc9e5
commit 4fbbbfdc76
7 changed files with 40 additions and 4 deletions
@@ -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 =