convert: fixed target size

This commit is contained in:
Thibault Deckers 2024-01-29 23:21:27 +01:00
parent b547b5b9b1
commit c9a0ae602b
2 changed files with 18 additions and 5 deletions

View file

@ -18,6 +18,12 @@ class AvesEntry(map: FieldMap) {
val isRotated: Boolean val isRotated: Boolean
get() = rotationDegrees % 180 == 90 get() = rotationDegrees % 180 == 90
val displayWidth: Int
get() = if (isRotated) height else width
val displayHeight: Int
get() = if (isRotated) width else height
companion object { companion object {
// convenience method // convenience method
private fun toLong(o: Any?): Long? = when (o) { private fun toLong(o: Any?): Long? = when (o) {

View file

@ -298,11 +298,18 @@ abstract class ImageProvider {
sourceDocFile.copyTo(output) sourceDocFile.copyTo(output)
} }
} else { } else {
var targetWidthPx: Int = if (sourceEntry.isRotated) height else width val targetWidthPx: Int
var targetHeightPx: Int = if (sourceEntry.isRotated) width else height val targetHeightPx: Int
if (lengthUnit == LENGTH_UNIT_PERCENT) { when (lengthUnit) {
targetWidthPx = sourceEntry.width * targetWidthPx / 100 LENGTH_UNIT_PERCENT -> {
targetHeightPx = sourceEntry.height * targetHeightPx / 100 targetWidthPx = sourceEntry.displayWidth * width / 100
targetHeightPx = sourceEntry.displayHeight * height / 100
}
else -> {
targetWidthPx = width
targetHeightPx = height
}
} }
val model: Any = if (pageId != null && MultiPageImage.isSupported(sourceMimeType)) { val model: Any = if (pageId != null && MultiPageImage.isSupported(sourceMimeType)) {