()
| 818 | } |
| 819 | |
| 820 | showPreview() { |
| 821 | if (!this.basePixelCanvas) return; |
| 822 | |
| 823 | const previewSection = document.getElementById('previewSection'); |
| 824 | const canvas = document.getElementById('pixelizerCanvas'); |
| 825 | |
| 826 | if (previewSection && canvas) { |
| 827 | previewSection.style.display = 'block'; |
| 828 | |
| 829 | // 复制基准像素图到预览canvas |
| 830 | canvas.width = this.basePixelCanvas.width; |
| 831 | canvas.height = this.basePixelCanvas.height; |
| 832 | const ctx = canvas.getContext('2d'); |
| 833 | ctx.imageSmoothingEnabled = false; |
| 834 | ctx.drawImage(this.basePixelCanvas, 0, 0); |
| 835 | |
| 836 | // 设置canvas样式以与原始图片保持一致的显示尺寸 |
| 837 | canvas.style.maxWidth = '100%'; |
| 838 | canvas.style.maxHeight = '100%'; |
| 839 | canvas.style.imageRendering = 'pixelated'; |
| 840 | canvas.style.objectFit = 'contain'; |
| 841 | |
| 842 | this.processedCanvas = canvas; |
| 843 | |
| 844 | // 应用默认400%缩放 |
| 845 | this.applyZoom(400); |
| 846 | |
| 847 | // 应用网格 |
| 848 | this.updateGridDisplay(); |
| 849 | this.setupCanvasInteraction(); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | setupCanvasInteraction() { |
| 854 | // 手动对齐功能已被移除 |
no test coverage detected