iTextSharp.text.pdf.BarcodeDatamatrix.CreateDrawingImage C# (CSharp) Method

CreateDrawingImage() public method

public CreateDrawingImage ( System foreground, System background ) : System.Drawing.Image
foreground System
background System
return System.Drawing.Image
        public virtual System.Drawing.Image CreateDrawingImage(System.Drawing.Color foreground, System.Drawing.Color background) {
            if (image == null)
                return null;
            int h = height + 2 * ws;
            int w = width + 2 * ws;
            int stride = (w + 7) / 8;
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(w, h);
            for (int k = 0; k < h; ++k) {
                int p = k * stride;
                for (int j = 0; j < w; ++j) {
                    int b = image[p + (j / 8)] & 0xff;
                    b <<= j % 8;
                    bmp.SetPixel(j, k, (b & 0x80) == 0 ? background : foreground);
                }
            }
            return bmp;
        }