Add title at top of merged image - white bg with dark text

This commit is contained in:
2026-03-06 22:36:59 +08:00
parent 3dff4be357
commit 16a32f6367
73 changed files with 37 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
#Fri Mar 06 22:14:48 CST 2026
#Fri Mar 06 22:33:52 CST 2026
path.4=14/classes.dex
path.3=12/classes.dex
path.2=10/classes.dex

View File

@@ -1 +1 @@
פ8מ)ת*ר'&ט%
פ8מ)ת*ר'&ט%<EFBFBD>!

View File

@@ -1 +1 @@
כXט¾ת¹ׁ~ּ>ֵפ­ן`¿ִJשֹןNװמ׳תbו4
ëXè¾ú¹Ñ~Ì>Åô­ï`ý¿ÄJùÉïNÔî×úbå4å²×?Í#

View File

@@ -199,23 +199,6 @@ fun MergeScreen(
.fillMaxSize()
.padding(paddingValues)
) {
// 顶部标题区域(如果设置了默认拼图标题)
if (title.isNotBlank()) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(16.dp)
) {
Text(
text = title,
style = MaterialTheme.typography.headlineSmall,
color = Color(0xFF333333),
modifier = Modifier.align(Alignment.Center)
)
}
}
// 布局选择
Row(
modifier = Modifier

View File

@@ -232,10 +232,18 @@ object ImageProcessor {
0f
}
// 顶部标题区域高度
val topTitleHeight = if (title.isNotBlank()) {
val titlePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = outputWidth / 20f
}
titlePaint.fontMetrics.let { it.descent - it.ascent } + 40f
} else 0f
// 图片区域高度
val imageAreaHeight = cellHeight * rows + cellSpacing * (rows + 1)
val outputHeight = imageAreaHeight + textAreaHeight.toInt()
val outputHeight = topTitleHeight.toInt() + imageAreaHeight + textAreaHeight.toInt()
val result = Bitmap.createBitmap(outputWidth, outputHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(result)
@@ -243,6 +251,27 @@ object ImageProcessor {
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
// 绘制顶部标题(白色背景+深色文字)
if (title.isNotBlank()) {
// 白色背景
canvas.drawRect(
0f, 0f,
outputWidth.toFloat(), topTitleHeight,
Paint().apply { color = android.graphics.Color.WHITE }
)
// 深色标题文字
val titlePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = outputWidth / 20f
color = android.graphics.Color.argb(255, 51, 51, 51) // 深灰色文字
typeface = Typeface.create("sans-serif", Typeface.BOLD)
textAlign = android.graphics.Paint.Align.CENTER
isAntiAlias = true
}
val titleY = topTitleHeight / 2 + titlePaint.fontMetrics.let { it.descent - it.ascent } / 2
canvas.drawText(title, outputWidth / 2f, titleY, titlePaint)
}
// 绘制图片网格
images.forEachIndexed { index, imageItem ->
if (index >= rows * cols) return@forEachIndexed
@@ -251,7 +280,7 @@ object ImageProcessor {
val row = index / cols
val left = cellSpacing + col * (cellWidth + cellSpacing)
val top = cellSpacing + row * (cellHeight + cellSpacing)
val top = topTitleHeight + cellSpacing + row * (cellHeight + cellSpacing)
try {
val sourceBitmap = tryLoadBitmap(context, imageItem)
@@ -259,7 +288,7 @@ object ImageProcessor {
sourceBitmap ?: return@forEachIndexed
val scaledBitmap = scaleAndCropBitmap(sourceBitmap, cellWidth, cellHeight)
val dstRect = Rect(left, top, left + cellWidth, top + cellHeight)
val dstRect = Rect(left.toInt(), top.toInt(), (left + cellWidth).toInt(), (top + cellHeight).toInt())
canvas.drawBitmap(scaledBitmap, null, dstRect, paint)
if (scaledBitmap != sourceBitmap) {
@@ -279,7 +308,7 @@ object ImageProcessor {
// 绘制底部文字区域
if (textAreaHeight > 0f) {
val textTop = imageAreaHeight
val textTop = topTitleHeight + imageAreaHeight
// 绘制统一的深灰色背景
val bgColor = android.graphics.Color.argb(255, 60, 60, 60) // 深灰色