Exemplo n.º 1
0
        public Image <Rgba32> Run(AlgorithmArgs args)
        {
            var builder = new StringRepresentationBuilder();
            var bits    = builder.ToCodabar($"{args.StartSymbol}{args.Text}{args.EndSymbol}");

            var @params = new CodabarParams(args.LineWidth, args.LineHeight);

            return(new BitmapConverter().Convert(bits, @params));
        }
Exemplo n.º 2
0
        public Image <Rgba32> Convert(string bits, CodabarParams codabarParams)
        {
            var image = new Image <Rgba32>(codabarParams.LineWidth * bits.Length,
                                           codabarParams.LineHeight);

            for (var i = 0; i < bits.Length; ++i)
            {
                var color = bits[i] == '1'
                    ? Rgba32.Black
                    : Rgba32.White;

                for (var j = i * codabarParams.LineWidth; j < (i + 1) * codabarParams.LineWidth; j++)
                {
                    for (var k = 0; k < codabarParams.LineHeight; k++)
                    {
                        image[j, k] = color;
                    }
                }
            }

            return(image);
        }