Codec di casa al posto di SkiaSharp (C1, passo 5)
SkiaSharp e SkiaSharp.NativeAssets.Linux.NoDependencies escono da Directory.Packages.props e da ogni progetto, per la regola «niente componenti esterni». Tutto ciò che leggeva, ridimensionava o disegnava immagini con Skia ora usa codice scritto in casa sulla BCL: - ImageResampler: Lanczos3 separabile o media per area, alfa premoltiplicata, luce lineare facoltativa; ImageGray per l'impronta. - Il lettore JPEG decodifica ridotto a 1/2, 1/4, 1/8; le miniature chiedono almeno il doppio del lato lungo, così l'ultimo passo resta a Lanczos e la miniatura resta uguale alla lettura intera. - ImageOrientation applica l'EXIF in un punto solo (miniature, impronte, anteprime, dimensioni mostrate). - ImageConverter cambia formato fra JPEG, PNG e WebP portando EXIF, ICC, XMP e testi, con l'etichetta d'orientamento e i pixel non ruotati; PngEncoder scrive anche i testi (tEXt o iTXt). - Febe.Core.Drawing: rasterizzatore con antialiasing (tracciati, riempimenti, tratti, gradienti) per icona, immagini dimostrative, riquadro neutro dei video, foto del sito di prova e prove. Febe.ico rigenerata. - ThumbnailStore legge anche i BMP a 24 bit, come quelli del decoder video del ramo funzione/decoder-h264. Le impronte salvate restano confrontabili (390 su 393 campioni identiche, le altre a distanza 2, soglia 6): nessun ricalcolo. Un PNG o JPEG troncato ora non ha miniatura né impronta. Documenti, elenco dei componenti della pagina «Informazioni» e decisioni aggiornati; nuove prove per ridimensionamento, orientamento, lettura ridotta, conversione con metadati, testi PNG e rasterizzatore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4383a6110
commit
d6a6a68496
47 files changed
+3391
-562
No files matched your search
@@ -1,8 +1,8 @@
|
||||
using System.Diagnostics;
|
||||
using Febe.Core.Codecs.Images;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Core.Storage;
|
||||
using Febe.Tests.Support;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Febe.Tests.Library;
|
||||
|
||||
@@ -15,7 +15,7 @@ public sealed class PerceptualHashTests
|
||||
|
||||
private static ulong Hash(byte[] encoded) => PerceptualHash.Compute(new MemoryStream(encoded)) ?? throw new AssertFailedException("Immagine non decodificata.");
|
||||
|
||||
private static ulong Hash(SKBitmap bitmap) => Hash(TestImages.Png(bitmap));
|
||||
private static ulong Hash(RgbaImage image) => Hash(TestImages.Png(image));
|
||||
|
||||
/// <summary>
|
||||
/// Calibration of <see cref="PerceptualHash.DuplicateThreshold"/> (spec §9.3, §14.1): resized and recompressed
|
||||
@@ -63,20 +63,20 @@ public sealed class PerceptualHashTests
|
||||
}
|
||||
|
||||
var side = Math.Min(width, height);
|
||||
var crops = new (string Name, SKRectI Area)[]
|
||||
var crops = new (string Name, (int Left, int Top, int Width, int Height) Area)[]
|
||||
{
|
||||
("centrale 80%", SKRectI.Create(width / 10, height / 10, width * 8 / 10, height * 8 / 10)),
|
||||
("centrale 75%", SKRectI.Create(width / 8, height / 8, width * 3 / 4, height * 3 / 4)),
|
||||
("centrale 60%", SKRectI.Create(width / 5, height / 5, width * 3 / 5, height * 3 / 5)),
|
||||
("lato sinistro tolto 10%", SKRectI.Create(width / 10, 0, width * 9 / 10, height)),
|
||||
("lato sinistro tolto 25%", SKRectI.Create(width / 4, 0, width * 3 / 4, height)),
|
||||
("in alto tolto 33%", SKRectI.Create(0, height / 3, width, height * 2 / 3)),
|
||||
("quadrato", SKRectI.Create((width - side) / 2, (height - side) / 2, side, side)),
|
||||
("quarto in basso a destra", SKRectI.Create(width / 2, height / 2, width / 2, height / 2)),
|
||||
("centrale 80%", (width / 10, height / 10, width * 8 / 10, height * 8 / 10)),
|
||||
("centrale 75%", (width / 8, height / 8, width * 3 / 4, height * 3 / 4)),
|
||||
("centrale 60%", (width / 5, height / 5, width * 3 / 5, height * 3 / 5)),
|
||||
("lato sinistro tolto 10%", (width / 10, 0, width * 9 / 10, height)),
|
||||
("lato sinistro tolto 25%", (width / 4, 0, width * 3 / 4, height)),
|
||||
("in alto tolto 33%", (0, height / 3, width, height * 2 / 3)),
|
||||
("quadrato", ((width - side) / 2, (height - side) / 2, side, side)),
|
||||
("quarto in basso a destra", (width / 2, height / 2, width / 2, height / 2)),
|
||||
};
|
||||
foreach (var (name, area) in crops)
|
||||
{
|
||||
using var cropped = TestImages.Crop(scene, area);
|
||||
using var cropped = TestImages.Crop(scene, area.Left, area.Top, area.Width, area.Height);
|
||||
var distance = PerceptualHash.Distance(original, Hash(TestImages.Jpeg(cropped, 90)));
|
||||
cropMin = Math.Min(cropMin, distance);
|
||||
Assert.IsGreaterThan(PerceptualHash.DuplicateThreshold, distance, $"Scena {seed}, ritaglio {name}: distanza {distance}");
|
||||
|
||||
Reference in new issue
Block a user