private void decodeButtonClick(object sender, EventArgs e) { var inputCode = this.codeTextbox.Text; inputCache.Insert(0, inputCode); inputBinding.ResetBindings(false); this.codeTextbox.Clear(); var invertedBinary = CodeInverter.TryInvert(inputCode, 2); var invertedTernary = CodeInverter.TryInvert(inputCode, 3); this.originalCodeDisplayLabel.Text = inputCode; this.invertedBinaryCodeDisplayLabel.Text = invertedBinary; this.invertedTernaryCodeDisplayLabel.Text = invertedTernary; var decoder = new CodeDecoder(); List <string[]> originalDecodeResults = decoder.Decodify(inputCode); List <string[]> invertedBinaryDecodeResults = decoder.Decodify(invertedBinary, CodeType.Binary); List <string[]> invertedTernaryDecodeResults = decoder.Decodify(invertedTernary, CodeType.Ternary); this.originalDecodeResultsTable.Items.Clear(); this.invertedDecodeResultsTable.Items.Clear(); this.PopulateListView(originalDecodeResults, this.originalDecodeResultsTable); this.PopulateListView(invertedBinaryDecodeResults, this.invertedDecodeResultsTable); this.PopulateListView(invertedTernaryDecodeResults, this.invertedDecodeResultsTable); }
static void Main(string[] args) { // quick and easy code encode string dummyText = @"A barcode (also bar code) is an optical, machine-readable representation of data; the data usually describes something about the object that carries the barcode. Traditional barcodes systematically represent data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D). Later, two-dimensional (2D) variants were developed, using rectangles, dots, hexagons and other geometric patterns, called matrix codes or 2D barcodes, although they do not use bars as such. Initially, barcodes were only scanned by special optical scanners called barcode readers."; CodeEncoder bc128 = CodeEncoder.CreateCode(CodeType.Code128, new TextPayload("7560001000234"), null, CodeRenderer.Create(CodeRenderType.Svg, new SvgRenderOptions() { m_iPixelPerModuleY = 20 })); //CodeRenderer.Create( CodeRenderType.Xaml) ); File.WriteAllText("test_code128.svg", bc128.Renderer.GetStringData()); // //string sTest128 = CodeDecoder.Decode(bc128.Data).Text; // quick and easy code encode CodeEncoder bcAztec = CodeEncoder.CreateCode(CodeType.Aztec, new TextPayload(dummyText), null, CodeRenderer.Create(CodeRenderType.Png, new PngRenderOptions(128, 128))); File.WriteAllBytes("test_aztec.png", bcAztec.Renderer.GetByteData()); // //string sTestAztec = CodeDecoder.Decode(bcAztec.Data).Text; string sTestAztecPng = CodeDecoder.Decode(File.ReadAllBytes("test_aztec.png")).Text; // multiple code render and data acquire CodeEncoder bcQRCode = CodeEncoder.CreateCode(CodeType.QR, new TextPayload(dummyText), null, CodeRenderer.Create(CodeRenderType.Png, new PngRenderOptions(256, 256))); File.WriteAllBytes("test_qr.png", bcQRCode.Renderer.GetByteData()); // //string sTestsQR=CodeDecoder.Decode( bcQRCode.Data ).Text; string sTestQRPng = CodeDecoder.Decode(File.ReadAllBytes("test_qr.png")).Text; // custom render CodeRenderer xSvgOutput = CodeRenderer.Create(CodeRenderType.Svg, new SvgRenderOptions()); xSvgOutput.Render(bcQRCode.Data); File.WriteAllText("test.svg", xSvgOutput.GetStringData()); // acquire data byte[] sPngData = bcQRCode.Renderer.GetByteData(); string sSvgData = xSvgOutput.GetStringData(); // SwissQR - payload Contact _contact = new Contact("John Doe", "3003", "Bern", "CH", "Parlamentsgebäude", "1"); Iban _iban = new Iban("CH2609000000857666015", Iban.IbanType.Iban); Reference _reference = new Reference(Reference.ReferenceType.QRR, "990005000000000320071012303", Reference.ReferenceTextType.QrReference); Currency _currency = Currency.CHF; decimal _amount = 100.25m; SwissQrCodePayload dataQR = new SwissQrCodePayload(_iban, _currency, _contact, _reference, null, _amount, null, null); CodeEncoder bcQRSwiss = CodeEncoder.CreateCode(CodeType.SwissQR, dataQR, null, CodeRenderer.Create(CodeRenderType.Png, new PngRenderOptions(256, 256))); File.WriteAllBytes("test_swissqr.png", bcQRSwiss.Renderer.GetByteData()); // //string sQRSwiss = CodeDecoder.Decode(bcQRSwiss.Data).Text; string sQRSwissPng = CodeDecoder.Decode(File.ReadAllBytes("test_swissqr.png")).Text; // MacroPDF417 SplitFile("~pdf417dump.cab.txt", "NetCore.seg", "001899017"); }