From 2238d632f78cee5ae93314810ce319ee0c83adc4 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Wed, 24 Dec 2025 19:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BA=90=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../powerbell/views/BackgroundView.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java index dd3d7e9..ade1f4c 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java @@ -126,6 +126,7 @@ public class BackgroundView extends RelativeLayout { // 设置图片背景色 mBgColor = bean.getPixelColor(); + LogUtils.d(TAG, String.format("loadByBackgroundBean() 背景色设置为 0x%08X", mBgColor)); // 判断是否使用背景文件 if (!bean.isUseBackgroundFile()) { @@ -138,7 +139,8 @@ public class BackgroundView extends RelativeLayout { String targetPath = bean.isUseBackgroundScaledCompressFile() ? bean.getBackgroundScaledCompressFilePath() : bean.getBackgroundFilePath(); - LogUtils.d(TAG, String.format("loadByBackgroundBean() 目标路径=%s", targetPath)); + LogUtils.d(TAG, String.format("loadByBackgroundBean() 目标路径=%s | 使用压缩文件=%b", + targetPath, bean.isUseBackgroundScaledCompressFile())); // 校验文件是否存在 File targetFile = new File(targetPath); @@ -151,7 +153,8 @@ public class BackgroundView extends RelativeLayout { } public void loadImage(int bgColor, String imagePath, boolean isRefresh) { - LogUtils.d(TAG, String.format("loadImage() 启动 | bgColor=0x%08X | imagePath=%s | isRefresh=%b", bgColor, imagePath, isRefresh)); + LogUtils.d(TAG, String.format("loadImage() 启动 | bgColor=0x%08X | imagePath=%s | isRefresh=%b", + bgColor, imagePath, isRefresh)); // 隐藏ImageView防止闪烁 mIvBackground.setVisibility(View.GONE); @@ -168,24 +171,25 @@ public class BackgroundView extends RelativeLayout { // 刷新逻辑:重新解码原始品质图片并更新缓存 if (isRefresh) { LogUtils.d(TAG, "loadImage() 执行刷新逻辑:重新解码原始品质图片"); - Bitmap newBitmap = decodeOriginalBitmap(new File(imagePath)); - // 合成纯色背景图片 -// Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor, -// appConfigUtils.mAppConfigBean.getDefaultFrameWidth(), -// appConfigUtils.mAppConfigBean.getDefaultFrameHeight(), -// newBitmap); - Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor, + File imageFile = new File(imagePath); + Bitmap newBitmap = decodeOriginalBitmap(imageFile); + LogUtils.d(TAG, String.format("loadImage() 原始图片解码完成 | newBitmap=%s", + newBitmap != null ? newBitmap.getWidth() + "x" + newBitmap.getHeight() : "null")); + + // 合成纯色背景图片(固定尺寸1197x2287) + Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor, 1197, 2287, newBitmap); - + if (combinedBitmap == null) { ToastUtils.show("合成背景图片失败,使用原始图片"); LogUtils.e(TAG, "loadImage() 纯色背景合成失败,使用原始Bitmap"); combinedBitmap = newBitmap; } else { ToastUtils.show("合成背景图片成功"); - LogUtils.d(TAG, "loadImage() 纯色背景合成成功"); + LogUtils.d(TAG, String.format("loadImage() 纯色背景合成成功 | combinedBitmap=%dx%d", + combinedBitmap.getWidth(), combinedBitmap.getHeight())); // 回收原始Bitmap(避免重复缓存) if (newBitmap != null && !newBitmap.isRecycled() && newBitmap != combinedBitmap) { newBitmap.recycle(); @@ -206,6 +210,8 @@ public class BackgroundView extends RelativeLayout { // 加载缓存图片 Bitmap cachedBitmap = App.sBitmapCacheUtils.getCachedBitmap(imagePath); + LogUtils.d(TAG, String.format("loadImage() 加载缓存图片 | cachedBitmap=%s", + cachedBitmap != null ? cachedBitmap.getWidth() + "x" + cachedBitmap.getHeight() : "null")); mIvBackground.setImageBitmap(cachedBitmap); mIvBackground.setScaleType(ImageView.ScaleType.FIT_CENTER); mIvBackground.setVisibility(View.VISIBLE);