Skip to content

Commit

Permalink
Removed try-catch and replaced by robust implementation in ArtQrCode …
Browse files Browse the repository at this point in the history
…small renderer
  • Loading branch information
codebude committed Apr 22, 2024
1 parent 3a994a6 commit af88109
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions QRCoder/ASCIIQRCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ public string GetGraphic(bool drawQuietZones = true, bool invert = false, string
try
{
var current = moduleData[col + quietZonesOffset][row + quietZonesOffset] ^ invert;
var next = moduleData[col + quietZonesOffset][(row + 1) + quietZonesOffset] ^ invert;
var nextRowId = row + quietZonesOffset + 1;

// Set next to whitespace "color"
var next = false ^ invert;
// Fill next with value, if in data range
if (nextRowId < QrCodeData.ModuleMatrix.Count)
next = moduleData[col + quietZonesOffset][nextRowId] ^ invert;

if (current == WHITE && next == WHITE)
lineBuilder.Append(palette.WHITE_ALL);
else if (current == WHITE && next == BLACK)
Expand All @@ -109,14 +116,6 @@ public string GetGraphic(bool drawQuietZones = true, bool invert = false, string
else
lineBuilder.Append(palette.BLACK_ALL);
}

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally

Check failure on line 118 in QRCoder/ASCIIQRCode.cs

View workflow job for this annotation

GitHub Actions / build

Expected catch or finally
catch (Exception)
{
if (drawQuietZones)
lineBuilder.Append(palette.WHITE_BLACK);
else
lineBuilder.Append(palette.BLACK_ALL);
}

}
lineBuilder.Append(endOfLine);
}
Expand Down

0 comments on commit af88109

Please sign in to comment.