Bladeren bron

Fix blurry cover preview: stop overwriting PDF PNG with scaled-down image

- unitCoverWorker.GeneratePdfCover now returns the pdftoppm output path without resaving\n- UI (Book.SetImage) already scales for display, and dialog now loads original file for crisp preview
Codex CLI 4 maanden geleden
bovenliggende
commit
2b4389c322
1 gewijzigde bestanden met toevoegingen van 3 en 30 verwijderingen
  1. 3 30
      src/unitCoverWorker.pas

+ 3 - 30
src/unitCoverWorker.pas

@@ -115,37 +115,10 @@ begin
 
   if FileExists(OutBase + '.png') then
   begin
+    // Return the full‑resolution PNG generated by pdftoppm.
+    // Do NOT overwrite it with a scaled-down image; scaling is handled in UI rendering.
     Result := OutBase + '.png';
-    // Scale down to requested cover size
-    if (W > 0) and (H > 0) then
-    begin
-      SrcImg := TLazIntfImage.Create(0, 0);
-      Img := TLazIntfImage.Create(W, H);
-      Canvas := TLazCanvas.Create(Img);
-      Png := TPortableNetworkGraphic.Create;
-      try
-        SrcImg.LoadFromFile(Result);
-        Img.FillPixels(colTransparent);
-        if (SrcImg.Width > 0) and (SrcImg.Height > 0) then
-        begin
-          scale := Min(W / SrcImg.Width, H / SrcImg.Height);
-          if scale > 1 then scale := 1;
-          dstW := Round(SrcImg.Width * scale);
-          dstH := Round(SrcImg.Height * scale);
-          offX := (W - dstW) div 2;
-          offY := (H - dstH) div 2;
-          Canvas.StretchDraw(offX, offY, dstW, dstH, SrcImg);
-        end;
-        Png.Assign(Img);
-        Png.SaveToFile(Result);
-        LogInfoFmt('Generated cover: %s', [Result]);
-      finally
-        Png.Free;
-        Canvas.Free;
-        Img.Free;
-        SrcImg.Free;
-      end;
-    end;
+    LogInfoFmt('Generated cover: %s', [Result]);
   end
   else
   begin