Barcode generator: unpredictable whitespace padding around it depending on requested Width

Aperta
#570 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Start with the ZXing.ImageSharp.BarcodeWriter call in the example, using CODE_39, Width = 400, Height = 400 and Margin = 0, and compare its output with the Width = 1 workaround. Find where the requested width is mapped onto the encoder's minimum module width, which the payload does not show, and make the extra space predictable. Done when a non-multiple width gives output whose bars fill the requested width with no unexplained horizontal padding.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

If you ask the barcode writer for an arbitrary width that isn't a multiple of the "default minimum" barcode width for that specific code, then you end up with unpredictable horizontal padding around the barcode.

an example:

public FileContentResult GithubExample()
{
    var code = "123456789";
    var barcodeWriter = new ZXing.ImageSharp.BarcodeWriter<Rgba32>
    {
        Format = BarcodeFormat.CODE_39,
        Options = new EncodingOptions
        {
            Height = 400,
            Width = 400,
            Margin = 0
        }
    };

    using var image = barcodeWriter.Write(code);;

    using var stream = new MemoryStream();

    var imageEncoder = new PngEncoder();
    var mime = "image/png";
    image.Save(stream, imageEncoder);

    var bytes = stream.ToArray();
    return File(bytes, mime);
}

result:
image

The workaround we currently have is to generate with Width = 1, then resize using ImageSharp after the fact. But it seems like something that ought to be handled by the generator anyway.

Lingua principale
C#
Stelle
3.1k
Fork
704
Merge medio
13g 17h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di micjahn/ZXing.Net

Tutte le issue di micjahn/ZXing.Net

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.