Beispiel #1
0
        public IBitmapImage Encode(string contents, int width, int height,
                                   string background = "#FFFBFEFF", string foreground = "#FF2D6178")
        {
            Color         backgroundColor = FromHex(background);
            Color         foregroundColor = FromHex(foreground);
            BarcodeWriter writer          = new BarcodeWriter()
            {
                Renderer = new ZXing.Rendering.BitmapRenderer()
                {
                    Background = backgroundColor,
                    Foreground = foregroundColor
                }
            };

            writer.Format  = BarcodeFormat.QR_CODE;
            writer.Options = new EncodingOptions {
                Margin = 0, Width = width, Height = height, PureBarcode = true
            };
            Bitmap         bmp  = writer.Write(contents);
            IBitmapFactory fact = Pici.Services.Get <IBitmapFactory>();

            return(fact.FromBitmap(bmp));
        }