Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions RdlCri/BarCodeEAN13.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ internal void DrawImage(Draw2.Bitmap bm, string upcode)
// Fill in the background with white
g.FillRectangle(Draw2.Brushes.White, 0, 0, bm.Width, bm.Height);

// Draw the bars
int barCount = LeftQuietZoneModules;
// Draw the bars - start from 0 to align left
int barCount = 0;
foreach (char bar in barPattern)
{
if (bar == '1')
{
float bh = ((barCount > ModulesToManufacturingStart && barCount < ModulesToManufacturingEnd) ||
(barCount > ModulesToProductStart && barCount < ModulesToProductEnd))
float bh = ((barCount > GuardModules && barCount < GuardModules + ManufacturingModules) ||
(barCount > GuardModules + ManufacturingModules + CenterBarModules && barCount < GuardModules + ManufacturingModules + CenterBarModules + ProductModules))
? barHeight - fontHeightMM
: barHeight;

Expand All @@ -159,22 +159,22 @@ internal void DrawImage(Draw2.Bitmap bm, string upcode)
// Draw the human readable portion of the barcode
using var f = new Draw2.Font("Arial", fontHeight);

// Draw the left guard text (i.e. 2nd digit of the NumberSystem)
// Draw the left guard text (i.e. 1st digit of the NumberSystem)
string wc = upcode.Substring(0, 1);
g.DrawString(wc, f, Draw2.Brushes.Black,
new Draw2.PointF(barWidth * LeftQuietZoneModules - g.MeasureString(wc, f).Width,
new Draw2.PointF(0,
barHeight - fontHeightMM));

// Draw the manufacturing digits
wc = upcode.Substring(1, 6);
g.DrawString(wc, f, Draw2.Brushes.Black,
new Draw2.PointF(barWidth * ModulesToManufacturingEnd - g.MeasureString(wc, f).Width,
new Draw2.PointF(barWidth * (GuardModules + ManufacturingModules) - g.MeasureString(wc, f).Width,
barHeight - fontHeightMM));

// Draw the product code + the checksum digit
wc = upcode.Substring(7, 5) + CheckSum(upcode).ToString();
g.DrawString(wc, f, Draw2.Brushes.Black,
new Draw2.PointF(barWidth * ModulesToProductEnd - g.MeasureString(wc, f).Width,
new Draw2.PointF(barWidth * (GuardModules + ManufacturingModules + CenterBarModules + ProductModules) - g.MeasureString(wc, f).Width,
barHeight - fontHeightMM));
}

Expand Down
10 changes: 9 additions & 1 deletion RdlCri/BarCodeITF14.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ private void InternalDraw(ref Bitmap bm, string value)

var img = Image.FromStream(v.Encode().AsStream());

bm = new Bitmap(img);
// Draw the barcode aligned to the left instead of replacing the bitmap
using (var g = Graphics.FromImage(bm))
{
// Fill background with white
g.FillRectangle(Brushes.White, 0, 0, bm.Width, bm.Height);

// Draw the barcode aligned to the left (top-left corner at 0, 0)
g.DrawImage(img, 0, 0);
}
}

public string GetCustomReportItemXml()
Expand Down
8 changes: 7 additions & 1 deletion RdlCri/ZxingBarcodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ internal void DrawImage(ref Draw2.Bitmap bm, string qrcode)
// The provider has already been registered.
}

bm = writer.Write(qrcode);
var barcodeBitmap = writer.Write(qrcode);

// Fill background with white
g.FillRectangle(Draw2.Brushes.White, 0, 0, bm.Width, bm.Height);

// Draw the barcode aligned to the left (top-left corner at 0, 0)
g.DrawImage(barcodeBitmap, 0, 0);
}

/// <summary>
Expand Down