/// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="Data">Raw data to encode.</param> /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param> /// <param name="DrawColor">Foreground color</param> /// <param name="BackColor">Background color</param> /// <param name="Width">Width of the resulting barcode.(pixels)</param> /// <param name="Height">Height of the resulting barcode.(pixels)</param> /// <param name="XML">XML representation of the data and the image of the barcode.</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, Color DrawColor, Color BackColor, int Width, int Height, ref string XML) { using (Barcode b = new Barcode()) { b.IncludeLabel = IncludeLabel; Image i = b.Encode(iType, Data, DrawColor, BackColor, Width, Height); XML = b.XML; return i; }//using }
/// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="Data">Raw data to encode.</param> /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param> /// <param name="DrawColor">Foreground color</param> /// <param name="BackColor">Background color</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, Color DrawColor, Color BackColor) { using (Barcode b = new Barcode()) { b.IncludeLabel = IncludeLabel; return b.Encode(iType, Data, DrawColor, BackColor); }//using }
/// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="data">Raw data to encode.</param> /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param> /// <param name="Width">Width of the resulting barcode.(pixels)</param> /// <param name="Height">Height of the resulting barcode.(pixels)</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel, int Width, int Height) { using (Barcode b = new Barcode()) { b.IncludeLabel = IncludeLabel; return b.Encode(iType, Data, Width, Height); }//using }
/// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="Data">Raw data to encode.</param> /// <param name="IncludeLabel">Include the label at the bottom of the image with data encoded.</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data, bool IncludeLabel) { using (Barcode b = new Barcode()) { b.IncludeLabel = IncludeLabel; return b.Encode(iType, Data); }//using }
/// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="Data">Raw data to encode.</param> /// <param name="XML">XML representation of the data and the image of the barcode.</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data, ref string XML) { using (Barcode b = new Barcode()) { Image i = b.Encode(iType, Data); XML = b.XML; return i; }//using }
}//CheckNumericOnly //private string GetXML() //{ // if (EncodedValue == "") // throw new Exception("EGETXML-1: Could not retrieve XML due to the barcode not being encoded first. Please call Encode first."); // else // { // try // { // using (BarcodeXML xml = new BarcodeXML()) // { // BarcodeXML.BarcodeRow row = xml.Barcode.NewBarcodeRow(); // row.Type = EncodedType.ToString(); // row.RawData = RawData; // row.EncodedValue = EncodedValue; // row.EncodingTime = EncodingTime; // row.IncludeLabel = IncludeLabel; // row.Forecolor = ColorTranslator.ToHtml(ForeColor); // row.Backcolor = ColorTranslator.ToHtml(BackColor); // row.CountryAssigningManufacturingCode = Country_Assigning_Manufacturer_Code; // row.ImageWidth = Width; // row.ImageHeight = Height; // row.RotateFlipType = this.RotateFlipType; // row.LabelPosition = this.LabelPosition; // row.LabelFont = this.LabelFont.ToString(); // row.ImageFormat = this.ImageFormat.ToString(); // row.Alignment = this.Alignment; // //get image in base 64 // using (MemoryStream ms = new MemoryStream()) // { // EncodedImage.Save(ms, ImageFormat); // row.Image = Convert.ToBase64String(ms.ToArray(), Base64FormattingOptions.None); // }//using // xml.Barcode.AddBarcodeRow(row); // StringWriter sw = new StringWriter(); // xml.WriteXml(sw, XmlWriteMode.WriteSchema); // return sw.ToString(); // }//using // }//try // catch (Exception ex) // { // throw new Exception("EGETXML-2: " + ex.Message); // }//catch // }//else //} //public static Image GetImageFromXML(BarcodeXML internalXML) //{ // try // { // //converting the base64 string to byte array // Byte[] imageContent = new Byte[internalXML.Barcode[0].Image.Length]; // //loading it to memory stream and then to image object // using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(internalXML.Barcode[0].Image))) // { // return Image.FromStream(ms); // }//using // }//try // catch (Exception ex) // { // throw new Exception("EGETIMAGEFROMXML-1: " + ex.Message); // }//catch //} #endregion #region Static Methods /// <summary> /// Encodes the raw data into binary form representing bars and spaces. Also generates an Image of the barcode. /// </summary> /// <param name="iType">Type of encoding to use.</param> /// <param name="Data">Raw data to encode.</param> /// <returns>Image representing the barcode.</returns> public static Image DoEncode(TYPE iType, string Data) { using (Barcode b = new Barcode()) { return b.Encode(iType, Data); }//using }