()
| 1098 | } |
| 1099 | |
| 1100 | updatePreviewIfNeeded() { |
| 1101 | // 如果已经有处理结果,实时更新预览 |
| 1102 | if (this.basePixelCanvas && !this.isProcessing) { |
| 1103 | // 对于颜色设置变化,重新处理图片 |
| 1104 | const colorCount = parseInt(document.getElementById('pixelColorCount').value) || 32; |
| 1105 | const enableDithering = document.getElementById('enableDithering').checked; |
| 1106 | const prefilterStrength = parseInt(document.getElementById('prefilterStrength').value) || 30; |
| 1107 | |
| 1108 | // 如果是手动模式的目标宽度变化,也需要重新处理 |
| 1109 | const detectionMode = document.querySelector('input[name="detectionMode"]:checked').value; |
| 1110 | |
| 1111 | if (detectionMode === 'manual') { |
| 1112 | // 手动模式下,重新处理图片 |
| 1113 | setTimeout(() => this.processImage(), 300); |
| 1114 | } else { |
| 1115 | // 自动模式下,只重新应用颜色量化 |
| 1116 | setTimeout(() => { |
| 1117 | this.applyColorQuantization().then(() => { |
| 1118 | this.showPreview(); |
| 1119 | }); |
| 1120 | }, 300); |
| 1121 | } |
| 1122 | } else { |
| 1123 | // 如果只是网格设置变化,只更新网格显示 |
| 1124 | setTimeout(() => this.updateGridDisplay(), 100); |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | showProgress(percent, message) { |
| 1129 | const progressSection = document.getElementById('progressSection'); |
no test coverage detected