Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When setting 'NoPadding=true', the 'SetPixels32()' method is causing the error 'SetPixels32 called with invalid number of pixels in the array'. #513

Open
gijunhan opened this issue Jul 31, 2023 · 1 comment

Comments

@gijunhan
Copy link

gijunhan commented Jul 31, 2023

When setting 'NoPadding=true', the 'SetPixels32()' method is causing the error 'SetPixels32 called with invalid number of pixels in the array'.

int w = 300;
int h = 300;
var options = new QrCodeEncodingOptions
{
	Width = w,
	Height = h,
	PureBarcode = false,
	Margin = 0,
	NoPadding = true
	
};
options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
var writer = new BarcodeWriter
{
	Format = BarcodeFormat.QR_CODE,
	Options = options
};
var pixels = writer.Write(qrCodeData);
var texture = new Texture2D(w, h);
texture.SetPixels32(pixels); // SetPixels32 called with invalid number of pixels in the array
texture.Apply();
@micjahn
Copy link
Owner

micjahn commented Aug 19, 2023

Which version of ZXing.Net do you use? Do you use the assembly from the main package of the release or from the binding package?
If possible you should use the assembly from the binding package. The BarcodeWriter implementation there has a slightly different result which contains the real height and width of the generated image.

...
var color32ImageData = writer.Write(qrCodeData);
var texture = new Texture2D(color32ImageData.Width, color32ImageData.Height);
texture.SetPixels32(color32ImageData.Pixels);
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants