Exemplo n.º 1
0
        public byte[] GetCodeContent(BarcodeInfo info, int sizeFactor, ImageFormat imageFormat)
        {
            BarcodeBitmap bmp = new BarcodeBitmap(info.Width, info.Width, sizeFactor);

            Color black = Color.Black;
            Color white = Color.White;

            for (int i = 0; i < info.Width; i++)
            {
                for (int j = 0; j < info.Width; j++)
                {
                    if (info.Data[j + i * info.Width] == 1)
                    {
                        bmp.SetPixel(j, i, black);
                    }
                    else
                    {
                        bmp.SetPixel(j, i, white);
                    }
                }
            }
            using (MemoryStream stream = new MemoryStream())
            {
                bmp.GetBitmap().Save(stream, imageFormat);
                byte[] content = new byte[stream.Length];
                return(stream.GetBuffer());
            }
        }
Exemplo n.º 2
0
        public void SaveImage(BarcodeInfo info, string filename, int sizeFactor)
        {
            _imageFileName = filename;
            BarcodeBitmap bmp = new BarcodeBitmap(info.Width, info.Width, sizeFactor);

            Color black = Color.Black;
            Color white = Color.White;

            for (int i = 0; i < info.Width; i++)
            {
                for (int j = 0; j < info.Width; j++)
                {
                    if (info.Data[j + i * info.Width] == 1)
                    {
                        bmp.SetPixel(j, i, black);
                    }
                    else
                    {
                        bmp.SetPixel(j, i, white);
                    }
                }
            }

            bmp.Save(_imageFileName, ImageFormat.Bmp);
        }
Exemplo n.º 3
0
        public BarcodeInfo GetBarcode(BarcodeData encodeData)
        {
            Matrix matrix = new Matrix();

            int width = 144;

            BarcodeInfo result = new BarcodeInfo();



            result.ResultCode =
                CreateDataMatrix(ref matrix, ref width, encodeData.Name, encodeData.Address,
                                 encodeData.Post, encodeData.Amount, encodeData.Receiving, encodeData.Notes,
                                 encodeData.Additions, encodeData.Department);

            result.Width = width;
            result.Data  = matrix.matrix;

            return(result);
        }
Exemplo n.º 4
0
 public byte[] GetCodeContent(BarcodeInfo info, ImageFormat imageFormat)
 {
     return(GetCodeContent(info, 2, imageFormat));
 }
Exemplo n.º 5
0
 public void SaveImage(BarcodeInfo barcodeInfo, string filename)
 {
     SaveImage(barcodeInfo, filename, 2);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Gets barcode of DataToEncode. DataToEncode property cannot be null.
        /// </summary>
        /// <returns></returns>
        public byte[] GetBarcode(ImageFormat imageFormat, int sizeFactor)
        {
            BarcodeInfo info = GetBarcodeInfo();

            return(_codeGenerator.GetCodeContent(info, sizeFactor, imageFormat));
        }