コード例 #1
0
        /// <summary>
        /// Encodes the raw data into binary form representing bars and spaces.
        /// </summary>
        internal Image Encode()
        {
            DateTime dtStartTime = DateTime.Now;

            //make sure there is something to encode
            if (Raw_Data.Trim() == "")
                throw new Exception("EENCODE-1: Input data not allowed to be blank.");

            if (this.EncodedType == TYPE.UNSPECIFIED)
                throw new Exception("EENCODE-2: Symbology type not allowed to be unspecified.");

            this.Encoded_Value = "";
            this._Country_Assigning_Manufacturer_Code = "N/A";

            IBarcode ibarcode;
            switch (this.Encoded_Type)
            {
                case TYPE.UCC12:
                case TYPE.UPCA: //Encode_UPCA();
                    ibarcode = new UPCA(Raw_Data);
                    break;
                case TYPE.UCC13:
                case TYPE.EAN13: //Encode_EAN13();
                    ibarcode = new EAN13(Raw_Data);
                    break;
                case TYPE.Interleaved2of5: //Encode_Interleaved2of5();
                    ibarcode = new Interleaved2of5(Raw_Data);
                    break;
                case TYPE.Industrial2of5:
                case TYPE.Standard2of5: //Encode_Standard2of5();
                    ibarcode = new Standard2of5(Raw_Data);
                    break;
                case TYPE.LOGMARS:
                case TYPE.CODE39: //Encode_Code39();
                    ibarcode = new Code39(Raw_Data);
                    break;
                case TYPE.CODE39Extended:
                    ibarcode = new Code39(Raw_Data, true);
                    break;
                case TYPE.Codabar: //Encode_Codabar();
                    ibarcode = new Codabar(Raw_Data);
                    break;
                case TYPE.PostNet: //Encode_PostNet();
                    ibarcode = new Postnet(Raw_Data);
                    break;
                case TYPE.ISBN:
                case TYPE.BOOKLAND: //Encode_ISBN_Bookland();
                    ibarcode = new ISBN(Raw_Data);
                    break;
                case TYPE.JAN13: //Encode_JAN13();
                    ibarcode = new JAN13(Raw_Data);
                    break;
                case TYPE.UPC_SUPPLEMENTAL_2DIGIT: //Encode_UPCSupplemental_2();
                    ibarcode = new UPCSupplement2(Raw_Data);
                    break;
                case TYPE.MSI_Mod10:
                case TYPE.MSI_2Mod10:
                case TYPE.MSI_Mod11:
                case TYPE.MSI_Mod11_Mod10:
                case TYPE.Modified_Plessey: //Encode_MSI();
                    ibarcode = new MSI(Raw_Data, Encoded_Type);
                    break;
                case TYPE.UPC_SUPPLEMENTAL_5DIGIT: //Encode_UPCSupplemental_5();
                    ibarcode = new UPCSupplement5(Raw_Data);
                    break;
                case TYPE.UPCE: //Encode_UPCE();
                    ibarcode = new UPCE(Raw_Data);
                    break;
                case TYPE.EAN8: //Encode_EAN8();
                    ibarcode = new EAN8(Raw_Data);
                    break;
                case TYPE.USD8:
                case TYPE.CODE11: //Encode_Code11();
                    ibarcode = new Code11(Raw_Data);
                    break;
                case TYPE.CODE128: //Encode_Code128();
                    ibarcode = new Code128(Raw_Data);
                    break;
                case TYPE.CODE128A:
                    ibarcode = new Code128(Raw_Data, Code128.TYPES.A);
                    break;
                case TYPE.CODE128B:
                    ibarcode = new Code128(Raw_Data, Code128.TYPES.B);
                    break;
                case TYPE.CODE128C:
                    ibarcode = new Code128(Raw_Data, Code128.TYPES.C);
                    break;
                case TYPE.ITF14:
                    ibarcode = new ITF14(Raw_Data);
                    break;
                case TYPE.CODE93:
                    ibarcode = new Code93(Raw_Data);
                    break;
                default: throw new Exception("EENCODE-2: Unsupported encoding type specified.");
            }//switch

            this.Encoded_Value = ibarcode.Encoded_Value;
            this.Raw_Data = ibarcode.RawData;
            this.Formatted_Data = ibarcode.FormattedData;
            this._EncodingTime = ((TimeSpan)(DateTime.Now - dtStartTime)).TotalMilliseconds;

            _Encoded_Image = (Image)Generate_Image();

            _XML = GetXML();

            return EncodedImage;
        }
コード例 #2
0
ファイル: BarcodeLib.cs プロジェクト: wangronghua/PEIS_Autoz
        }//Encode()

        /// <summary>
        /// Encodes the raw data into binary form representing bars and spaces.
        /// </summary>
        internal Bitmap Encode()
        {
            //make sure there is something to encode
            if (Raw_Data.Trim() == "")
            {
                throw new Exception("EENCODE-1: Input data not allowed to be blank.");
            }

            if (this.EncodedType == TYPE.UNSPECIFIED)
            {
                throw new Exception("EENCODE-2: Symbology type not allowed to be unspecified.");
            }

            this.Encoded_Value = "";
            this._Country_Assigning_Manufacturer_Code = "N/A";

            IBarcode ibarcode;

            switch (this.Encoded_Type)
            {
            case TYPE.UCC12:
            case TYPE.UPCA:     //Encode_UPCA();
                ibarcode = new UPCA(Raw_Data);
                break;

            case TYPE.UCC13:
            case TYPE.EAN13:     //Encode_EAN13();
                ibarcode = new EAN13(Raw_Data);
                break;

            case TYPE.Interleaved2of5:     //Encode_Interleaved2of5();
                ibarcode = new Interleaved2of5(Raw_Data);
                break;

            case TYPE.Industrial2of5:
            case TYPE.Standard2of5:     //Encode_Standard2of5();
                ibarcode = new Standard2of5(Raw_Data);
                break;

            case TYPE.LOGMARS:
            case TYPE.CODE39:     //Encode_Code39();
                ibarcode = new Code39(Raw_Data);
                break;

            case TYPE.CODE39Extended:
                ibarcode = new Code39(Raw_Data, true);
                break;

            case TYPE.Codabar:     //Encode_Codabar();
                ibarcode = new Codabar(Raw_Data);
                break;

            case TYPE.PostNet:     //Encode_PostNet();
                ibarcode = new Postnet(Raw_Data);
                break;

            case TYPE.ISBN:
            case TYPE.BOOKLAND:     //Encode_ISBN_Bookland();
                ibarcode = new ISBN(Raw_Data);
                break;

            case TYPE.JAN13:     //Encode_JAN13();
                ibarcode = new JAN13(Raw_Data);
                break;

            case TYPE.UPC_SUPPLEMENTAL_2DIGIT:     //Encode_UPCSupplemental_2();
                ibarcode = new UPCSupplement2(Raw_Data);
                break;

            case TYPE.MSI_Mod10:
            case TYPE.MSI_2Mod10:
            case TYPE.MSI_Mod11:
            case TYPE.MSI_Mod11_Mod10:
            case TYPE.Modified_Plessey:     //Encode_MSI();
                ibarcode = new MSI(Raw_Data, Encoded_Type);
                break;

            case TYPE.UPC_SUPPLEMENTAL_5DIGIT:     //Encode_UPCSupplemental_5();
                ibarcode = new UPCSupplement5(Raw_Data);
                break;

            case TYPE.UPCE:     //Encode_UPCE();
                ibarcode = new UPCE(Raw_Data);
                break;

            case TYPE.EAN8:     //Encode_EAN8();
                ibarcode = new EAN8(Raw_Data);
                break;

            case TYPE.USD8:
            case TYPE.CODE11:     //Encode_Code11();
                ibarcode = new Code11(Raw_Data);
                break;

            case TYPE.CODE128:     //Encode_Code128();
                ibarcode = new Code128(Raw_Data);
                break;

            case TYPE.CODE128A:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.A);
                break;

            case TYPE.CODE128B:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.B);
                break;

            case TYPE.CODE128C:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.C);
                break;

            case TYPE.ITF14:
                ibarcode = new ITF14(Raw_Data);
                break;

            case TYPE.CODE93:
                ibarcode = new Code93(Raw_Data);
                break;

            default: throw new Exception("EENCODE-2: Unsupported encoding type specified.");
            }//switch

            this.Encoded_Value  = ibarcode.Encoded_Value;
            this.Raw_Data       = ibarcode.RawData;
            this.Formatted_Data = ibarcode.FormattedData;

            return(Generate_Image());
        }//Encode