You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we have upgraded to net core 6 we are rewriting some of our code base. We have a tag helper in AspNet Core which generates a barcode. This currently uses System.Drawing and ZXing.
TagHelper Old version using System.Drawing - working (top barcode)
publicoverridevoidProcess(TagHelperContextcontext,TagHelperOutputoutput){varmargin=0;varqrCodeWriter=new ZXing.BarcodeWriterPixelData
{Format= ZXing.BarcodeFormat.PDF_417,Options=new ZXing.Common.EncodingOptions
{Height=this.Height >80?this.Height :80,Width=this.Width >400?this.Width :400,Margin=margin}};varpixelData= qrCodeWriter.Write(QRCodeContent);// creating a bitmap from the raw pixel data; if only black and white colors are used it makes no difference// that the pixel data ist BGRA oriented and the bitmap is initialized with RGBusing(varbitmap=new Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))using(varms=new MemoryStream()){varbitmapData= bitmap.LockBits(new Rectangle(0,0, pixelData.Width, pixelData.Height),
System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);try{// we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image
System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels,0, bitmapData.Scan0,
pixelData.Pixels.Length);}finally{
bitmap.UnlockBits(bitmapData);}// save to stream as PNG
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
output.TagName ="img";
output.Attributes.Clear();
output.Attributes.Add("width", Width);
output.Attributes.Add("height", Height);
output.Attributes.Add("alt", Alt);
output.Attributes.Add("src",$"data:image/png;base64,{Convert.ToBase64String(ms.ToArray())}");}}
TagHelper new version using ImageSharp - almost working but not exactly (bottom barcode)
As we have upgraded to net core 6 we are rewriting some of our code base. We have a tag helper in AspNet Core which generates a barcode. This currently uses System.Drawing and ZXing.
TagHelper Old version using System.Drawing - working (top barcode)
TagHelper new version using ImageSharp - almost working but not exactly (bottom barcode)
The issue is as mentioned the 2nd barcode is very slightly different at the end seems to extend the last bar.
What am I missing?
The text was updated successfully, but these errors were encountered: