public override System.Drawing.Image CreateDrawingImage(System.Drawing.Color foreground, System.Drawing.Color background) {
String fullCode = code;
if (generateChecksum && checksumText)
fullCode = CalculateChecksum(code);
if (!startStopText)
fullCode = fullCode.Substring(1, fullCode.Length - 2);
byte[] bars = GetBarsCodabar(generateChecksum ? CalculateChecksum(code) : code);
int wide = 0;
for (int k = 0; k < bars.Length; ++k) {
wide += (int)bars[k];
}
int narrow = bars.Length - wide;
int fullWidth = narrow + wide * (int)n;
int height = (int)barHeight;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(fullWidth, height);
for (int h = 0; h < height; ++h) {
bool print = true;
int ptr = 0;
for (int k = 0; k < bars.Length; ++k) {
int w = (bars[k] == 0 ? 1 : (int)n);
System.Drawing.Color c = background;
if (print)
c = foreground;
print = !print;
for (int j = 0; j < w; ++j)
bmp.SetPixel(ptr++, h, c);
}
}
return bmp;
}
}