protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { //10 narrow space queit zone + 2 narrow bars for the STOP width += (codes.Count * 11 * settings.NarrowWidth) + (2 * 10 * settings.NarrowWidth) + (2 * settings.NarrowWidth); return(base.OnCalculateWidth(width, settings, codes)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { foreach (int item in codes) { width += (PatternSet[item].NarrowCount * settings.NarrowWidth) + (PatternSet[item].WideCount * settings.WideWidth); } return(base.OnCalculateWidth(width, settings, codes)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { foreach (int item in codes) { width += (PatternSet[item].WideCount * settings.WideWidth) + (PatternSet[item].NarrowCount * settings.NarrowWidth); } return base.OnCalculateWidth(width, settings, codes); }
/// <summary> /// Modify the height /// </summary> /// <param name="height">calculated pixel height</param> /// <param name="codes">parsed value</param> /// <returns>new pixel height</returns> protected virtual int OnCalculateHeight(int height, BarcodeSettings settings, CodedValueCollection codes) { height = settings.TopMargin + settings.BarHeight + settings.BottomMargin; if (settings.IsTextShown) { height += Convert.ToInt32(settings.Font.GetHeight()) + settings.TextPadding; } return(height); }
public BarcodeBase(BarcodeSettings settings) { DefaultSettings = settings; Init(); if (PatternSet == null) { lock (TheLock) { if (PatternSet == null) CreatePatternSet(); } } }
public BarcodeBase(BarcodeSettings settings) { DefaultSettings = settings; Init(); if (PatternSet == null) { lock (TheLock) { if (PatternSet == null) { CreatePatternSet(); } } } }
/// <summary> /// Calculates the size of the barcode image & sets the margins if a size is defined /// </summary> /// <param name="settings">setting in use with this barcode</param> /// <param name="codes">The encoded barcode data</param> /// <returns>size of the resultant image</returns> private Size GetDimensions(BarcodeSettings settings, CodedValueCollection codes) { int width = OnCalculateWidth(0, settings, codes); int height = OnCalculateHeight(0, settings, codes); if (settings.MaxWidth > 0 && width > settings.MaxWidth) { throw new BarcodeSizeException("The barcode width exceeds the maximum allowed width"); } if (settings.MaxHeight > 0 && height > settings.MaxHeight) { throw new BarcodeSizeException("The barcode height exceeds the maximum allowed height"); } if (settings.Width > 0) { if (settings.Width < width) { throw new BarcodeSizeException("The barcode width is larger than the defined width"); } settings.LeftMargin = (settings.Width - width) / 2; settings.RightMargin = settings.Width - width - settings.LeftMargin; width = settings.Width; } if (settings.Height > 0) { if (settings.Height < height) { throw new BarcodeSizeException("The barcode height is larger than the defined height"); } settings.TopMargin = (settings.Height - height) / 2; settings.BottomMargin = settings.Height - height - settings.TopMargin; height = settings.Height; } return(new Size((int)Math.Ceiling(width * settings.Scale), (int)Math.Ceiling(height * settings.Scale))); }
/// <summary> /// Main function to draw the barcode /// </summary> /// <param name="settings">setting in use with this barcode</param> /// <param name="text">text to encode</param> /// <returns>bitmap image of the barcode</returns> protected Bitmap Paint(BarcodeSettings settings, string text) { State state = new State(settings, settings.LeftMargin, settings.TopMargin); state.Codes = new CodedValueCollection(); state.Text = ParseText(text, state.Codes); if (settings.IsChecksumCalculated) { AddChecksumEventArgs args = new AddChecksumEventArgs(state); OnAddChecksum(args); state.Text = args.Text; } Size size = GetDimensions(settings, state.Codes); Bitmap b = new Bitmap(size.Width, size.Height); //, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale); state.Canvas = Graphics.FromImage(b); Paint(state); return(b); }
/// <summary> /// Main entry point for generating the barcode /// </summary> /// <param name="text">text to encode</param> /// <param name="settings">setting to use to overide the defaults</param> /// <returns>bitmap of the generated barcode</returns> public Bitmap Generate(string text, BarcodeSettings settings) { return(Paint(settings, text)); }
/// <summary> /// Calculates the size of the barcode image & sets the margins if a size is defined /// </summary> /// <param name="settings">setting in use with this barcode</param> /// <param name="codes">The encoded barcode data</param> /// <returns>size of the resultant image</returns> private Size GetDimensions(BarcodeSettings settings, CodedValueCollection codes) { int width = OnCalculateWidth(0, settings, codes); int height = OnCalculateHeight(0, settings, codes); if (settings.MaxWidth > 0 && width > settings.MaxWidth) throw new BarcodeSizeException("The barcode width exceeds the maximum allowed width"); if (settings.MaxHeight > 0 && height > settings.MaxHeight) throw new BarcodeSizeException("The barcode height exceeds the maximum allowed height"); if (settings.Width > 0) { if (settings.Width < width) throw new BarcodeSizeException("The barcode width is larger than the defined width"); settings.LeftMargin = (settings.Width - width) / 2; settings.RightMargin = settings.Width - width - settings.LeftMargin; width = settings.Width; } if (settings.Height > 0) { if (settings.Height < height) throw new BarcodeSizeException("The barcode height is larger than the defined height"); settings.TopMargin = (settings.Height - height) / 2; settings.BottomMargin = settings.Height - height - settings.TopMargin; height = settings.Height; } return new Size((int)Math.Ceiling(width * settings.Scale), (int)Math.Ceiling(height * settings.Scale)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (settings.NarrowWidth * ((codes.Count * 7) + 11)) + (DigitGrouping[0] * 7 * settings.NarrowWidth); return base.OnCalculateWidth(width, settings, codes); }
/// <summary> /// Main entry point for generating the barcode /// </summary> /// <param name="text">text to encode</param> /// <param name="settings">setting to use to overide the defaults</param> /// <returns>bitmap of the generated barcode</returns> public Bitmap Generate(string text, BarcodeSettings settings) { return Paint(settings, text); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (settings.NarrowWidth * ((codes.Count * 7) + 11)) + (DigitGrouping[0] * 7 * settings.NarrowWidth); return(base.OnCalculateWidth(width, settings, codes)); }
public State(BarcodeSettings settings, int left, int top) { Left = left; Top = top; Settings = settings; }
/// <summary> /// Modify the width calculation /// </summary> /// <param name="width">calculated pixel width</param> /// <param name="codes">parsed value</param> /// <returns>new pixel width</returns> protected virtual int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { return width + settings.LeftMargin + settings.RightMargin + ((codes.Count - 1) * settings.ModulePadding); }
public Bitmap Generate(GS1.GS1Builder value, BarcodeSettings settings) { AiMarker = value.FNC1; _Value = value; return(Generate(value.ToString(), settings)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { //10 narrow space queit zone + 2 narrow bars for the STOP width += (codes.Count * 11 * settings.NarrowWidth) + (2 * 10 * settings.NarrowWidth) + (2 * settings.NarrowWidth); return base.OnCalculateWidth(width, settings, codes); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (settings.WideWidth + settings.NarrowWidth) * 27; //1+8+5+4+8+1 return base.OnCalculateWidth(width, settings, codes); }
/// <summary> /// Modify the width calculation /// </summary> /// <param name="width">calculated pixel width</param> /// <param name="codes">parsed value</param> /// <returns>new pixel width</returns> protected virtual int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { return(width + settings.LeftMargin + settings.RightMargin + ((codes.Count - 1) * settings.ModulePadding)); }
protected override int OnCalculateHeight(int height, BarcodeSettings settings, CodedValueCollection codes) { height -= (settings.BarHeight - settings.MediumHeight); return(base.OnCalculateHeight(height, settings, codes)); }
/// <summary> /// Modify the height /// </summary> /// <param name="height">calculated pixel height</param> /// <param name="codes">parsed value</param> /// <returns>new pixel height</returns> protected virtual int OnCalculateHeight(int height, BarcodeSettings settings, CodedValueCollection codes) { height = settings.TopMargin + settings.BarHeight + settings.BottomMargin; if (settings.IsTextShown) height += Convert.ToInt32(settings.Font.GetHeight()) + settings.TextPadding; return height; }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (codes.Count * ((7 * settings.NarrowWidth) + (2 * settings.WideWidth))); width += (14 * settings.NarrowWidth); return base.OnCalculateWidth(width, settings, codes); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += ((-23) * settings.NarrowWidth); return(base.OnCalculateWidth(width, settings, codes)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width = settings.NarrowWidth * (codes.Count - 1); return(base.OnCalculateWidth(width, settings, codes)); }
protected override int OnCalculateHeight(int height, BarcodeSettings settings, CodedValueCollection codes) { height -= (settings.BarHeight - settings.MediumHeight); return base.OnCalculateHeight(height, settings, codes); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (((4 * settings.WideWidth) + (6 * settings.NarrowWidth)) * codes.Count) + (6 * settings.NarrowWidth) + settings.WideWidth; return(base.OnCalculateWidth(width, settings, codes)); }
public Bitmap Generate(GS1.GS1Builder value, BarcodeSettings settings) { AiMarker = value.FNC1; _Value = value; return Generate(value.ToString(), settings); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (codes.Count * ((7 * settings.NarrowWidth) + (2 * settings.WideWidth))); width += (14 * settings.NarrowWidth); return(base.OnCalculateWidth(width, settings, codes)); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += ((codes.Count - 1) * 9 * settings.NarrowWidth) + settings.NarrowWidth; return base.OnCalculateWidth(width, settings, codes); }
protected override int OnCalculateWidth(int width, BarcodeSettings settings, CodedValueCollection codes) { width += (settings.WideWidth + settings.NarrowWidth) * 27; //1+8+5+4+8+1 return(base.OnCalculateWidth(width, settings, codes)); }
/// <summary> /// Main function to draw the barcode /// </summary> /// <param name="settings">setting in use with this barcode</param> /// <param name="text">text to encode</param> /// <returns>bitmap image of the barcode</returns> protected Bitmap Paint(BarcodeSettings settings, string text) { State state = new State(settings, settings.LeftMargin, settings.TopMargin); state.Codes = new CodedValueCollection(); state.Text = ParseText(text, state.Codes); if (settings.IsChecksumCalculated) { AddChecksumEventArgs args = new AddChecksumEventArgs(state); OnAddChecksum(args); state.Text = args.Text; } Size size = GetDimensions(settings, state.Codes); Bitmap b = new Bitmap(size.Width, size.Height);//, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale); state.Canvas = Graphics.FromImage(b); Paint(state); return b; }