feat: 拼图质量改为分辨率缩放,高清80%/标准50%/流畅30%
This commit is contained in:
@@ -51,10 +51,10 @@ enum class LocationMode {
|
||||
/**
|
||||
* 图片质量
|
||||
*/
|
||||
enum class ImageQuality(val quality: Int, val displayName: String) {
|
||||
High(100, "高清"),
|
||||
Standard(85, "标准"),
|
||||
Low(70, "流畅")
|
||||
enum class ImageQuality(val quality: Int, val displayName: String, val scaleFactor: Float) {
|
||||
High(100, "高清", 0.8f),
|
||||
Standard(85, "标准", 0.5f),
|
||||
Low(70, "流畅", 0.3f)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -520,7 +520,7 @@ fun MergeScreen(
|
||||
context,
|
||||
imageItems,
|
||||
layoutType,
|
||||
imageQuality,
|
||||
ImageQuality.High,
|
||||
title,
|
||||
content,
|
||||
titleStyle,
|
||||
|
||||
@@ -231,10 +231,28 @@ object ImageProcessor {
|
||||
val cols = layoutType.cols
|
||||
val rows = layoutType.rows
|
||||
|
||||
val outputWidth = 1920
|
||||
val cellSpacing = 16 // 单元格间距 16px (约 4dp * 4)
|
||||
val cellWidth = (outputWidth - cellSpacing * (cols + 1)) / cols
|
||||
val cellHeight = cellWidth // 保持正方形格子
|
||||
val cellSpacing = 16
|
||||
val maxCellDimension = 800
|
||||
|
||||
// 根据第一张图片的原始尺寸确定单元格宽高比
|
||||
val firstBitmap = images.firstOrNull()?.let { tryLoadBitmap(context, it) }
|
||||
val (srcW, srcH) = if (firstBitmap != null) {
|
||||
Pair(firstBitmap.width, firstBitmap.height).also { firstBitmap.recycle() }
|
||||
} else {
|
||||
Pair(1, 1)
|
||||
}
|
||||
|
||||
// 基准单元格大小(限制不超过maxCellDimension)
|
||||
val longer = maxOf(srcW, srcH)
|
||||
val baseScale = if (longer > maxCellDimension) maxCellDimension.toFloat() / longer else 1.0f
|
||||
val baseCellWidth = (srcW * baseScale).toInt()
|
||||
val baseCellHeight = (srcH * baseScale).toInt()
|
||||
|
||||
// 根据质量等级缩放
|
||||
val cellWidth = (baseCellWidth * quality.scaleFactor).toInt().coerceAtLeast(1)
|
||||
val cellHeight = (baseCellHeight * quality.scaleFactor).toInt().coerceAtLeast(1)
|
||||
|
||||
val outputWidth = (cellWidth * cols + cellSpacing * (cols + 1)).coerceAtLeast(480)
|
||||
|
||||
// 底部文字区域高度 - 动态计算
|
||||
val textAreaHeight = if (bottomTitle.isNotBlank() || bottomContent.isNotBlank()) {
|
||||
|
||||
Reference in New Issue
Block a user