[X] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
XamlQRCode should not crash ...
Current Behavior
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.'
Possible Solution (optional)
XamlQRCode loops on the size adding doubles together hoping to get to the width/height. Adding doubles don't always round to the value you would normally expect. You should loop on the QRCode size and add pixel for placement instead.
double x = 0;
double y;
for (int xi = offsetModules; xi < QrCodeData.ModuleMatrix.Count - offsetModules; ++xi)
{
y = 0;
for (int yi = offsetModules; yi < QrCodeData.ModuleMatrix.Count - offsetModules; ++yi)
{
if (this.QrCodeData.ModuleMatrix[yi + offsetModules][xi + offsetModules])
{
group.Children.Add(new RectangleGeometry(new Rect(x, y, unitsPerModule, unitsPerModule)));
}
y += unitsPerModule;
}
x += unitsPerModule;
}
Steps to Reproduce (for bugs)
var generator = new QRCodeGenerator();
var data = generator.CreateQrCode("Something that ends up with a size 41 QRCode", QRCodeGenerator.ECCLevel.Q);
var xaml = new XamlQRCode(data);
Code = xaml.GetGraphic(new Size(200, 200), Brushes.Black, Brushes.White);
Type of issue
[X] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
XamlQRCode should not crash ...
Current Behavior
Possible Solution (optional)
XamlQRCode loops on the size adding doubles together hoping to get to the width/height. Adding doubles don't always round to the value you would normally expect. You should loop on the QRCode size and add pixel for placement instead.
Steps to Reproduce (for bugs)
Your Environment
Version Used: QRCoder 1.3.3 from NuGet