iTextSharp.text.pdf.BarcodeEAN.CreateDrawingImage C# (CSharp) Метод

CreateDrawingImage() публичный Метод

public CreateDrawingImage ( System foreground, System background ) : System.Drawing.Image
foreground System
background System
Результат System.Drawing.Image
        public override System.Drawing.Image CreateDrawingImage(System.Drawing.Color foreground, System.Drawing.Color background) {
            int width = 0;
            byte[] bars = null;
            switch (codeType) {
                case EAN13:
                    bars = GetBarsEAN13(code);
                    width = 11 + 12 * 7;
                    break;
                case EAN8:
                    bars = GetBarsEAN8(code);
                    width = 11 + 8 * 7;
                    break;
                case UPCA:
                    bars = GetBarsEAN13("0" + code);
                    width = 11 + 12 * 7;
                    break;
                case UPCE:
                    bars = GetBarsUPCE(code);
                    width = 9 + 6 * 7;
                    break;
                case SUPP2:
                    bars = GetBarsSupplemental2(code);
                    width = 6 + 2 * 7;
                    break;
                case SUPP5:
                    bars = GetBarsSupplemental5(code);
                    width = 4 + 5 * 7 + 4 * 2;
                    break;
                default:
                    throw new InvalidOperationException("Invalid code type.");
            }
            int height = (int)barHeight;
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, 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];
                    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;
        }
    }