micjahn / zxing.net Goto Github PK
View Code? Open in Web Editor NEW.Net port of the original java-based barcode reader and generator library zxing
License: Apache License 2.0
.Net port of the original java-based barcode reader and generator library zxing
License: Apache License 2.0
Hi,
I'm getting the same symptoms as described here: zxing/zxing#202
ie decode multiple results in the top-right; bottom-right or bottom-left scan ok but give incorrect result points. I looked at the .net version source-code and it seems to be attempting to make the points absolute similar to this: zxing/zxing@0111b72
Unable to set ZxingScannerPage Icon like so:
var scanPage = new ZXingScannerPage(options, overlay)
{
Icon = "somePng.png"
};
Hello,
Could anyone give me any insight as to why this cannot be decoded and always returns null? Attached the image and below is my code.
var decoder = new BarcodeReader();
decoder.Options = new ZXing.Common.DecodingOptions() { PureBarcode = true, TryHarder = true, PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.DATA_MATRIX } };
decoder.AutoRotate = true;
decoder.TryInverted = true;
var results = decoder.Decode(new Bitmap(filename_datamatrix));
RSS14Reader.cs
242 recordPattern(row, pattern.StartEnd[1] + 1, counters);
Return value is ignored. But recordPattern may return false.
And array will contains all zeros.
Then
253 float elementWidth = (float)ZXing.Common.Detector.MathUtils.sum(counters) / (float)numModules;
will be zero.
And error here
262 float value = (float)counters[i] / elementWidth;
Is there a guide to how to use zxing.dll with SSRS 2016?
I have done all that should be required to use zxing.dll with SSRS but can't get past this error:
[rsRuntimeErrorInExpression] The Value expression for the image ‘Image1’ contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The security error is generated when I use the BarCodeWriter.Write method.
This project is really useful and I would like to use it, but I'm stumped.
Thanks. Tim
I tried to generate a simple numeric QR code with the content "123456".
But when i decode the generated qr code on https://zxing.org/w/decode.jspx it says that is is type text.
I just use the write method here.
Is there a way to force a numeric QR code?
Hi,
I am trying to read barcode from Color scanned tiff file and it is not working as expected.
Please help me out on this.
I have attached the image for your reference
07212017165503.zip
.
I know this was a mirror initially of the subversion repo on codeplex, but given codeplex is shutting down, do you plan on making this repo the actual source home?
Love that it's here as I can submodule it now for my library!
Is it possible to build a PDF417 barcode from HEX? I tried something with ZXing, but it wont work with an encoded string in my case.
HEX: fe-30-**09**-33-31-37-30-31-30-32-30-31-f9-20-**01**-34-fe-30-**01**-20-fc-20-**06**
I highlighted some Hexchars which won't work (e.g 09, 01, 06).
The main problem is that our HEX has to be converted into a string, before being able to generate a pdf417 barcode and no encoding (ascii, utf-8, etc.) supports those hexcharacters.
Is there a way to get a byte array into the generator or somehow make sure that, when reading the barcode, these characters will be displayed correctly?
Other than that ZXing fits all my needs, but I cant find a propper way of using my data in this case.
Hi,
I have used BarcodeWriter class to generate a code128 barcode. Can you tell me how to set font type and font size in the generated barcode bitmap?
Alex
I'm not quite sure if your example code in the readme file is working in .Net 4.0. But it definitely isn't in .Net 4.5. It should be var barcodeBitmap = (Bitmap)Image.FromFile("C:\\sample-barcode-image.png");
instead of var barcodeBitmap = (Bitmap)Bitmap.LoadFrom("C:\\sample-barcode-image.png");
.
So in total:
// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// load a bitmap
var barcodeBitmap = (Bitmap)Image.FromFile("C:\\sample-barcode-image.png");
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);
// do something with the result
if (result != null)
{
txtDecoderType.Text = result.BarcodeFormat.ToString();
txtDecoderContent.Text = result.Text;
}
help,
need :
simple C# code example for barcode reader from file(.tif , .png , .pdf) including it's references (.dll)
what exactly .dll's needed to refrence, and from what directory to copy
one page class.cs will help .
regards,
EL
FYI An internal error occurred. Please contact Microsoft Product Support Services.
basically i need to show QRCode (.NETCoreApp 1.1) and thought the ASP.NetCoreDemo is a good start but it requires ZXing.CoreCompat.System.Drawing
is there any other possibility to display a QRCode without ZXing.CoreCompat.System.Drawing ?
How can I rebuild the zxing.unity.dll? So far, I have:
At that point, I get errors wherever unity classes/namespaces are used (Color32, UnityEngine, etc).
Thanks,
Eric
I'm not able to scan 2d datamatrix codes. Is this a feature that doesn't exist, or an issue with my barcode generator?
i found this https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/BarcodeWriter.SvgImage.cs but i am not able to generate svg file is there any way?
I followed instructions, copied both zxing.dll and zxing.interop.dll to c:\windows and from there with admin rights run register.cmd
It registered, but now in VBA Access, I can not add a reference. It is not listed, and if clicking on browse, and selecting the dll , I get the error - "Can't add a reference to the specified file."
How can I add this to work?
When encoding a DataMatrix the code substitutes ASCII character 29 (<GS>) with the FNC1 character where FNC1 is defined as (char)232
. Code here
I believe this is a mistake.
ISO/IEC 16022:2006 Section 5.2.4.6 "FNC1 alternate data type identifier" (emphasis mine)
To encode data to conform to specific industry standards as authorised by AIM Inc., a FNC1 character shall appear in the first or second symbol character position (or in the fifth or sixth data positions of the first symbol of Structured Append). FNC1 encoded in any other position is used as a field separator and shall be transmitted as GS control character (ASCII value 29).
Essentially the FNC1 character used at the start of the DataMatrix and during the data are different, and the wrong one is being inserted.
Despite this, a DataMatrix produced using an FNC1 representation of 232 instead of 29 to delimit variable data still passes verification, but the output is not the same as other DataMatrix encoders I've seen.
I believe it can be fixed by replacing this else:
else
{
if (c == 29)
{
context.writeCodeword((char)HighLevelEncoder.FNC1);
}
else
{
context.writeCodeword((char)(c + 1));
}
context.Pos++;
}
with this:
else
{
context.writeCodeword((char)(c + 1));
context.Pos++;
}
I suspected that the lookahead methods may need modifying to accept the GS character (\u001D
). For example adding to the check isNativeText(char ch)
in HighLevelEncoder.cs
but I'm not sure about this.
internal static bool isNativeText(char ch)
{
return (ch == ' ') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || ch == '\u001D';
}
Hey I found ZXing does not work well with Datamatrix codes.
Also, using the BarcodeReader-Class with Options.PossibleFormats set to DATA_MATRIX does not find Datamatrix-Codes, even PureBarcode ones with a high quality.
However, the DataMatrixReader will find some.
Did I misconfigure something? How come the generic reader does not find them?
Thank you for porting this over to .Net
ByQuadrantReader
should check for result == null
at line 103. If the last decode attempt fails, this line throws NullReferenceException
.
The default definition for Black in NET CORE is new Color(0) which has an alpha channel of 0. This causes the SVG Renderer to render a transparent svg.
I am overriding your defaults such that Foreground = new Color() { A = 255, R = 0, B = 0, G = 0 }
Works perfectly then.
Thanks.
Have unusual requirement and was wondering it could use ZXing without mods. I am rpelacing an old Foxpro application which generates a Code 128 string into and extract. So not the bar code image, but the intermediate string after converting the raw string input internally to Code 128. for instance the free online encoder page from ID Automation (http://www.bcgen.com/fontencoder/) converts the string "MA$7#LXB #000074232088" to the corresponding Code 128 string "ÌMA$7#LXBÂÂ#ÇÂÂj74x.Î".
Because the consumer of my extract is not changing I need to be able to generate the string as the old app did. I expect that the string is generated within ZXing internally while generating a Code 128 barcode bitmap.
Am asking only if you can answer of the top of your head. If not, I'd be glad to go into the code and research myself.
Thanks in advance for any help and for mantaingin the great product....--Al-
The attached image doesn't successfully read the QR code, even though the identical image has no problem at https://zxing.org/w/decode.jspx
I'm working on where a barcode will form when a button is pressed but for some reason the width won't change, it stays tiny, this is in Unity 5.5.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ZXing;
using ZXing.Rendering;
public class Barcode : MonoBehaviour {
//public float calcPrice;
public static float price;
public static string print;
public static bool error = false;
private bool show = false;
public GameObject generateBttn;
[SerializeField] Button Bcode;
public Calculator calc;
// Use this for initialization
void Awake () {
calc = GetComponent<Calculator> ();
}
// Update is called once per frame
void Update () {
if (show) {
generateBttn.GetComponent<Image> ().color = Color.green;
} else {
generateBttn.GetComponent<Image> ().color = Color.red;
}
if (error) {
errorMessage ();
}
price = Mathf.RoundToInt (calc.chargePrice);
}
public void reset(){
error = false;
}
public void setCode(float charge){
price = Mathf.RoundToInt (calc.chargePrice);
}
private static Color32[] Encode (string textForEncoding, int width, int height)
{
var writer = new BarcodeWriter {
Format = BarcodeFormat.CODE_39,
Options = new ZXing.Common.EncodingOptions
{Height = height,Width = width}
};
if (price < 0) {
print = ("02043541000" + price);
}
else if (price < 10 && price >= 0) {
print = ("0204354100" + price + "99");
}
else if (price < 100 && price >= 10) {
print = ("020435410" + price + "99");
}
else if (price >= 100 && price < 1000) {
print = ("02043541" + price + "99");
}
else if (price > 1000) {
print = 00000.ToString();
error = true;
//errorMessage ();
}
//}
return writer.Write (print);
}
public void errorMessage(){
show = false;
calc.barcodeError ("There has been an error, app is not calibrated to print barcodes over $1,000.00. We appologize for the inconvenience");
error = false;
}
public Texture2D generateCode(string text) {
var encoded = new Texture2D (256, 300); //256
var color32 = Encode (text, encoded.width, encoded.height);
encoded.SetPixels32 (color32);
encoded.Apply ();
return encoded;
}
public void showBrcode(){
if (show) {
show = false;
} else {
show = true;
}
}
void OnGUI(){
if (show && price != 0) {
Texture2D bbCode = generateCode ("Arrangement");
if (GUI.Button (new Rect ( Screen.width/2, Screen.height/2, 1000, 500), bbCode, GUIStyle.none)) {
}
;
}
}
}
"var encoded = new Texture2D (256, 300); //256"
when I change the variables here the only variable that takes effect is the height but the width will stay the same even after changing the variable.
Am I missing something or is there a different way of changing the width?
Hi,
I'm using zxing on Unity3D and I noticed the default orientation is vertical. For my use case I need to scan horizontally but I can't find how to rotate the default scan orientation. For now I can make it work using both AutoRotate = true
and TryHarder = true
but it slow down the process (since each image is processed in different orientations).
Any idea of how to do that? Thanks.
Hello,
I'm having an issue decoding one specific QR code. I have not had any issues with any others that were generated from the same source except this particular one. I have attached the image below. This QR code image is scanned from a piece of paper just FYI. Decode returns null on the result.
Text value should be : 37d59b9d-ad37-11e7-a3da-2e6a680acb2
Thanks!
-Kent
I was using Zxing.net library for a project but unable to detect barcodes tilted at an angle other than multiples of 90 degree.
Nuget Package is v 0.14.0.1 from 2014. Last commit was in december 2016, is there any reason it cant be updated?
Hi,
Im using Zxing.Net for Bar code detection. Most of the cases its working fine. But for few images im facing an issue when the barcode is rotated. I have attached the sample bar code image for reference.
Im using the zxing library with below options,
this.reader = new BarcodeReader()
{
AutoRotate = true,
Options = new DecodingOptions()
{
TryHarder = true,
PossibleFormats = new List<BarcodeFormat>
{
BarcodeFormat.EAN_8
},
},
TryInverted = true
};
Please suggest how can the accuracy can be improved with different rotations of attached images.
Note: I cant stop the rotation as user captures the print out of bar code image.
Hi,
when I use the example for the GS1 Code128 Barcode, the FNC1 is shown as a "n with Tilde".
Is there any trick to print it in brackets?
Hallo,
How can I change the fontsize under the Barcode?
Is it possible to change the font too?
I have a simple VBA app, where I can use the command line to get an QR code image. Everything works great, I just need more options for the commandLineEncoder. I am missing options for ErrorCorrection, ECI, symbolversion etc... , I do not have VisualStudio to fix it myself.
On the other hand, I would use the new ZXing.Net with VBA (COM Interop) but can not do it because I will need to register it on every users computer.
I am already using freeimage.dll which I can simply load with using
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
and loading it by
Function FreeImgLoad(ByVal dllFilename As String) As Boolean
If FreeDLLhm = 0 Then
' attempt to load the module
FreeDLLhm = LoadLibrary(dllFilename)
If FreeDLLhm > 0 Then
FreeImgLoad = True
End If
End If
End Function
and then using its functions by
Public Declare Function FreeImage_HasPixelsInt Lib "FreeImage.dll" Alias "_FreeImage_HasPixels@4" ( _
ByVal Bitmap As Long) As Long
Is it possible to use the dll for zxing in the same way? Or am I barking up the wrong tree? :)
[Searched and didn't see this so adding.]
The statement:
Enum.TryParse("ALL_1D", out BarcodeFormat format)
returns false. It should return true with the format variable filled with the BarcodeFormat.ALL_1D value. It works correctly with all the other recognized codes.
Hi, I noticed you are using strange indentation in files - 3 spaces. Is it intentional or issue caused by auto conversion or sth?
Edit: I found many other code formatting issues and inconsistency, for example below there aren't spaces between arithmetic operators:
float q = distance(poutd, pouta)*nbCenterLayers/(distance(pind, pina)*(nbCenterLayers + 2));
but sometimes even in the same file, spaces appeared:
var pinax = new ResultPoint(pina.X + 0.5f, pina.Y - 0.5f);
I want to create DataMatrix Codes with a fixed length of 15 characters. But there is a formating issue with the following Code using the NuGet v0.16.2:
var dmWriter = new ZXing.BarcodeWriter() { Format = ZXing.BarcodeFormat.DATA_MATRIX };
dmWriter.Options.PureBarcode = true;
//Output OK
var t = dmWriter.Write("0000319%0009367%S");
t.Save("tmp_fine.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
//Output NOK
t = dmWriter.Write("000319%009367%S");
t.Save("tmp_bad.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
When I use 17 characters, everything is OK. With 15 characters, the barcode is displayed blurred. See the attached pictures.
Hello,
I have a problem referencing one of my projects which is dependent on zxing. All my projects target .NET4.0. This is the error I get:
The primary reference "D:\fakepath\Assembly1.dll" could not be resolved because it has an indirect dependency on the assembly "zxing, Version=0.15.0.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60" which was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".
I double checked this and I'm sure I'm referencing the net40 version from the nuget package. Probably this version was built with net461?
Thanks,
Panayot
Although not broken the rendering of SVG QR Codes could be improved by setting the shape-rendering
attribute to crispEdges
on the generated SVG element to remove anti-aliasing artefacts.
The images below were rendered by Chrome Version 57.0.2987.98 (64-bit) with the results being replicated in Firefox 52.0 (64-bit)
How can I get a black and white image from barcode.write(). What I get is 24 bit 1.03MB big full color image.
I convert it to 1bpp with this
var x = ZXing.QrCode.Internal.ErrorCorrectionLevel.H;
var barcodeWriter = new BarcodeWriter
{
Format = barcodeFormat,
Options = new ZXing.QrCode.QrCodeEncodingOptions
{
CharacterSet = "ISO-8859-2",
Width = 600,
Height = 600,
ErrorCorrection = x,
QrVersion = 15
}
};
var bitmap = barcodeWriter.Write("ASDASD");
Console.Out.WriteLine(bitmap.PixelFormat);
var targetBmp = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), pixelFormat.Format1bppIndexed);`
Console.Out.WriteLine(targetBmp.PixelFormat);
But barcodewriter first creates 24bit color 1MB big image, and then I convert it to 1 bit per pixel image which is 43Kb. Is there a parameter where I can set QR code to be just black and white? I have to create 2000 QR codes, and this is just too slow... :(
Hello,
I'm trying to use zxing.unity.dll on the HoloLens. I'm so close.
When building, I'm getting the following error, related to System.ComponentModel.BrowsableAttribute:
Reference rewriter: Error: type System.ComponentModel.BrowsableAttribute doesn't exist in target framework.
There are about 4 of these errors that reference this namespace in various places. I saw a video online of someone who was successful in deploying ZXing to Unity/HoloLens, but they didn't mention this issue. I'm not sure if it's some version difference. But anyway, here are some specs:
Thank you!
Eric
I have found that a Code 128 barcode image is improperly decoded as UPC_E when the image is at an angle but a second image of the same barcode is properly decoded as Code 128. Note the images below. The angled image returns the incorrect barcode format and value but the approx. 90 degree image works fine.
Correct Code 128 value:
X000WDQ1V3
Improperly decoded value as UPC_E:
00522047
Note that this happens in my own code but also is the same issue in the WindowsFormsDemo application that comes with this distribution. I've tried forcing Code 128 as the only format but then it just fails to decode.
The defaults for the WindowsFormsDemo are checked:
enable Auto Rotate
enable Try Harder
enable Try Inverted
I run the windowsformdemo in the project zxing.vs2015, and found there is Extra blank space on the right and bottom in the DataMatrix barcode bitmap image when set the height and width of the barcode.
Is there a way to avoid this , because the image is too small (height = 12 or 14) when using the default height and width?
Hi, I'm stuck with a problem i hope u can help me to solve.
I want to use your incredible good library on my FEZ SPIDER using 4.3 version of .net framework but i can't build it! How can I use your lib with this versione of the fw?
Thank you so much
Using VB6 and the COM Interop module, I can retrieve the PixelData object, but am unable to retrieve the actual bitmap and place it in a picture box on screen.
I have tried several different APIs including OleLoadPicture from a Stream of bytes and assigning it to an IPicture etc. but nothing worked.
My solution was create a couple of new methods on IBarcodeWriter and the BarcodeWriter class to a) save the image as a BMP as it loads natively in VB6 whereas a PNG requires some API manipulation, and b) return the barcode bitmap as an IPicture that can be assigned directly to the PictureBox.Picture property.
This works nicely with VB6.
I can now use PictureBox.Picture = writer.write("text to be encoded as a barcode")
I have attached my modified version of the zxing.interop module
interop.zip
Please add support for .NET Core (netstandard).
Would it be possible that you push 0.16 to nuget? Milestone (https://github.com/micjahn/ZXing.Net/milestone/1?closed=1) seems complete, and I am currently having the .NET Core transparent svg image problem (see #22). I would be happy to get rid of my regex fixing this right now.
Thx.
Moved this issue to zxing/zxing.
Hi Michael,
Are you planning on porting zxing.kinect to Kinect 2.0 anytime soon?
Best Regards,
Maxime Beck
Hi Michael, with my colleagues we want to use:
ZXing.EncodeHintType.ERROR_CORRECTION
But we do not find documentation on this point
Could you help us? :) #ZXing
NET Core 2.0 CoreCompat.System.Drawing adapter should reference package CoreCompat.System.Drawing.v2 otherwise there are type name collisions with netstandard2.0 library.
Hi there, I'm trying to generate a barcode (Code_39, 93 or 128) as an SVG inAsp.Net Core but I can't find a way to display the textual value beneath the generated barcode.
As of my understanding, that's what the "PureBarcode" setting is for, but it doesn't seem to change anything setting it explicitely to true/false.
Is there something I'm missing here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.