Пример #1
0
        /// <summary>
        /// Generates an EAN-8, EAN-13, or UPC-A 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[] GetBarcodeEAN_UPC(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.EncodeBarcodeDataEAN_UPC(data, barcodeType);

            // Create an image using encodedData and save the image to a byte array:
            byte[] imgData = BarcodesRenderer.GetBarcodeImageEAN_UPC(encodedData, data, barcodeType, showDataLabel, heightToCut, scaleMultiplier, lineColor, 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);
        }