barnhill / barcodelib

C# Barcode Image Generation Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After Update, It doesnt work.

sraban75 opened this issue · comments

This is My old code. and it works fine, but after upgrading from 2.4 to 3.0, It doesn't work

var barcode = new Barcode();
barcode.ImageFormat = ImageFormat.Png;
barcode.IncludeLabel = includeLabel;
using var image = barcode.Encode(TYPE.CODE128, code);
await using var m = new MemoryStream();
image.Save(m, ImageFormat.Png);
var imageBytes = m.ToArray();

 BarcodeStandard.Barcode barcode = new BarcodeStandard.Barcode();
 barcode.IncludeLabel = includeLabel;
 barcode.EncodedType = BarcodeStandard.Type.Code128;
 barcode.Encode(BarcodeStandard.Type.Code128, code);

You can try to save the image directly through the package instead of doing all this with memorystream

barcode.SaveImage(path, BarcodeStandard.SaveTypes.Png);