public static Image GetBarcodeImage(string barCodeValue, int width, int height) { if (barCodeValue.Length == 12) { barCodeValue += getUPCACheckDigit(barCodeValue); } com.google.zxing.oned.EAN13Writer writer = new com.google.zxing.oned.EAN13Writer(); com.google.zxing.common.ByteMatrix matrix = writer.encode(barCodeValue, com.google.zxing.BarcodeFormat.EAN_13, width, height); System.Drawing.Image drawingBarCode = matrix.ToBitmap(); // convert drawing to imageSource Image imageBarCode = new Image(); imageBarCode.Source = ImageHelper.DrawingImageToBitmapImage(drawingBarCode); return(imageBarCode); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public com.google.zxing.common.BitMatrix encode(String contents, BarcodeFormat format, int width, int height, java.util.Map<EncodeHintType,?> hints) throws WriterException public BitMatrix encode(string contents, BarcodeFormat format, int width, int height, IDictionary<EncodeHintType, object> hints) { Writer writer; switch (format) { case com.google.zxing.BarcodeFormat.EAN_8: writer = new EAN8Writer(); break; case com.google.zxing.BarcodeFormat.EAN_13: writer = new EAN13Writer(); break; case com.google.zxing.BarcodeFormat.UPC_A: writer = new UPCAWriter(); break; case com.google.zxing.BarcodeFormat.QR_CODE: writer = new QRCodeWriter(); break; case com.google.zxing.BarcodeFormat.CODE_39: writer = new Code39Writer(); break; case com.google.zxing.BarcodeFormat.CODE_128: writer = new Code128Writer(); break; case com.google.zxing.BarcodeFormat.ITF: writer = new ITFWriter(); break; case com.google.zxing.BarcodeFormat.PDF_417: writer = new PDF417Writer(); break; case com.google.zxing.BarcodeFormat.CODABAR: writer = new CodaBarWriter(); break; default: throw new System.ArgumentException("No encoder available for format " + format); } return writer.encode(contents, format, width, height, hints); }