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()); } }
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); }
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); }
public byte[] GetCodeContent(BarcodeInfo info, ImageFormat imageFormat) { return(GetCodeContent(info, 2, imageFormat)); }
public void SaveImage(BarcodeInfo barcodeInfo, string filename) { SaveImage(barcodeInfo, filename, 2); }
/// <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)); }