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
get() = rotationDegrees % 180 == 90
val displayWidth: Int
get() = if (isRotated) height else width
val displayHeight: Int
get() = if (isRotated) width else height
companion object {
// convenience method
private fun toLong(o: Any?): Long? = when (o) {

View file

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