Skip to content

Commit

Permalink
Removed unused code and unnecessary ref keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
codebude committed Jun 23, 2024
1 parent 9a0f73d commit 86c2e47
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions QRCoder/BitmapByteQRCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgb, byte[] lightC
ix += _bitmapHeaderPart1.Length;

// Filesize
CopyIntAs4ByteToArray(fileSize, ix, ref bmp);
CopyIntAs4ByteToArray(fileSize, ix, bmp);
ix += 4;

// Header part 2
Array.Copy(_bitmapHeaderPart2, 0, bmp, ix, _bitmapHeaderPart2.Length);
ix += _bitmapHeaderPart2.Length;

// Width
CopyIntAs4ByteToArray(sideLength, ix, ref bmp);
CopyIntAs4ByteToArray(sideLength, ix, bmp);
ix += 4;
// Height
CopyIntAs4ByteToArray(sideLength, ix, ref bmp);
CopyIntAs4ByteToArray(sideLength, ix, bmp);
ix += 4;

// Header end
Expand All @@ -106,7 +106,6 @@ public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgb, byte[] lightC


// Draw qr code
var group = new byte[(int)(sideLength / pixelsPerModule) * moduleDark.Length];
for (var x = sideLength - 1; x >= 0; x -= pixelsPerModule)
{
var modMatrixX = (x + pixelsPerModule) / pixelsPerModule - 1;
Expand All @@ -116,7 +115,6 @@ public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgb, byte[] lightC
for (var y = 0; y < sideLength; y += pixelsPerModule)
{
var module = QrCodeData.ModuleMatrix[modMatrixX][(y + pixelsPerModule) / pixelsPerModule - 1];
Array.Copy(module ? moduleDark : moduleLight, 0, group, y / pixelsPerModule * moduleDark.Length, moduleDark.Length);
Array.Copy(module ? moduleDark : moduleLight, 0, bmp, ix, moduleDark.Length);
ix += moduleDark.Length;
}
Expand Down Expand Up @@ -159,7 +157,7 @@ private byte[] HexColorToByteArray(string colorString)
/// <param name="inp">The integer to convert.</param>
/// <param name="destinationIndex">Index of destinationArray where the converted bytes are written to</param>
/// <param name="destinationArray">Destination byte array that receives the bytes</param>
private void CopyIntAs4ByteToArray(int inp, int destinationIndex, ref byte[] destinationArray)
private void CopyIntAs4ByteToArray(int inp, int destinationIndex, byte[] destinationArray)
{
unchecked
{
Expand Down

0 comments on commit 86c2e47

Please sign in to comment.