/// <summary> /// Generates a GS1-128 barcode image from the input data and returns the image as an array of bytes. /// </summary> /// <param name="data">The input data for the barcode.</param> /// <param name="barcodeType">The barcode type.</param> /// <param name="lineColor">The color of barcode lines.</param> /// <param name="backColor">The background color.</param> /// <param name="showDataLabel">Defines whether the input data is printed under the barcode lines.</param> /// <param name="heightToCut">The height in pixels or in percent to be cut from the top of the barcode lines to reduce the standard height.</param> /// <param name="scaleMultiplier">The multiplier of the barcode width for better text rendering.</param> /// <param name="hasQuietZones">Defines whether the barcode has quiet zones.</param> /// <param name="barcodeRotation">Defines barcode rotation angle.</param> /// <returns>Array of bytes</returns> internal static byte[] GetBarcodeGS1_128(string data, BarcodeType barcodeType, System.Drawing.Color lineColor, System.Drawing.Color backColor, bool showDataLabel, MeasureBarcodeUnit heightToCut, int scaleMultiplier = 2, bool hasQuietZones = true, BarcodeRotation barcodeRotation = BarcodeRotation.Clockwise_0) { // Process the data and encode it: byte[] encodedData = BarcodesEncoder.EncodeBarcodeDataGS1_128(data, barcodeType); // Create an image using encodedData and save the image to a byte array: byte[] imgData = BarcodesRenderer.GetBarcodeImageGS1_128(encodedData, data, heightToCut, showDataLabel, scaleMultiplier, strokeColor: lineColor, backColor: backColor, hasQuietZones, barcodeRotation); return(imgData); }
public void Test_Encoder_EAN_UPC(BarcodeType type, string caseName) { switch (type) { case BarcodeType.EAN_13: BarcodesEncoder.EncodeBarcodeDataEAN_UPC(BarcodesTestData.inputTestStringEAN_13, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataEAN_13); break; case BarcodeType.EAN_8: BarcodesEncoder.EncodeBarcodeDataEAN_UPC(BarcodesTestData.inputTestStringEAN_8, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataEAN_8); break; case BarcodeType.UPC_A: BarcodesEncoder.EncodeBarcodeDataEAN_UPC(BarcodesTestData.inputTestStringUPC_A, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataUPC_A); break; } Assert.True(true, caseName); }
public void Test_Encoder_GS1_128(BarcodeType type, string caseName) { switch (type) { case BarcodeType.GS1_128A: BarcodesEncoder.EncodeBarcodeDataGS1_128(BarcodesTestData.inputTestStringGS1_128A, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataGS1_128A); break; case BarcodeType.GS1_128B: BarcodesEncoder.EncodeBarcodeDataGS1_128(BarcodesTestData.inputTestStringGS1_128B, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataGS1_128B); break; case BarcodeType.GS1_128C: BarcodesEncoder.EncodeBarcodeDataGS1_128(BarcodesTestData.inputTestStringGS1_128C, type) .Should().BeEquivalentTo(BarcodesTestData.encodedTestDataGS1_128C); break; } Assert.True(true, caseName); }