Example #1
0
        private static MediaVisionSource GenerateSource(BarcodeGenerationConfiguration config,
                                                        string message, BarcodeType type, int qrMode, int qrEcc, int qrVersion)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            ValidationUtil.ValidateEnum(typeof(BarcodeType), type);

            MediaVisionSource source = new MediaVisionSource();

            try
            {
                InteropBarcode.GenerateSource(EngineConfiguration.GetHandle(config),
                                              message, type, qrMode, qrEcc, qrVersion, source.Handle).
                Validate("Failed to generate source");
            }
            catch (Exception)
            {
                source.Dispose();
                throw;
            }
            return(source);
        }
Example #2
0
        /// <summary>
        /// Generates a barcode image with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
        /// </summary>
        /// <param name="message">The message to be encoded in the barcode.</param>
        /// <param name="type">Type of the barcode to be generated.</param>
        /// <param name="config">The configuration of the barcode generator. This value can be null.</param>
        /// <returns><see cref="MediaVisionSource"/> containing the generated barcode image.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="message"/> is too long.<br/>
        ///     -or-<br/>
        ///     <paramref name="type"/> is <see cref="BarcodeType.QR"/>.<br/>
        ///     -or-<br/>
        ///     <paramref name="type"/> is invalid.<br/>
        ///     -or-<br/>
        ///     <paramref name="message"/> contains illegal characters.
        /// </exception>
        /// <exception cref="NotSupportedException">The feature is not supported.</exception>
        /// <exception cref="ObjectDisposedException"><paramref name="config"/> already has been disposed of.</exception>
        /// <since_tizen> 4 </since_tizen>
        public static MediaVisionSource GenerateSource(string message, BarcodeType type,
                                                       BarcodeGenerationConfiguration config)
        {
            if (type == BarcodeType.QR)
            {
                throw new ArgumentException($"Invalid barcode type : {type}.");
            }

            return(GenerateSource(config, message, type, NoneQrMode, NoneErrorCorrection, 0));
        }
Example #3
0
        /// <summary>
        /// Generates a QR image file with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
        /// </summary>
        /// <remarks>
        ///     <see cref="BarcodeGenerationConfiguration.TextVisibility"/> must be <see cref="Visibility.Invisible"/>,
        ///     because the text visibility is not supported in the QR code.
        /// </remarks>
        /// <param name="message">The message to be encoded in the barcode.</param>
        /// <param name="qrConfig">The <see cref="QrConfiguration"/> instance.</param>
        /// <param name="imageConfig">The <see cref="BarcodeImageConfiguration"/> that contains
        ///     information about the file to be generated.</param>
        /// <param name="config">The configuration of the barcode generator. This value can be null.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="message"/> is null.<br/>
        ///     -or-<br/>
        ///     <paramref name="qrConfig"/> is null.<br/>
        ///     -or-<br/>
        ///     <paramref name="imageConfig"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="message"/> is too long.<br/>
        ///     -or-<br/>
        ///     <paramref name="message"/> contains characters which are illegal by the <see cref="QrMode"/>.
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">No permission to write a file.</exception>
        /// <exception cref="NotSupportedException">
        ///     The feature is not supported.<br/>
        ///     -or-<br/>
        ///     <see cref="BarcodeGenerationConfiguration.TextVisibility"/> is the <see cref="Visibility.Visible"/>.
        /// </exception>
        /// <exception cref="ObjectDisposedException"><paramref name="config"/> already has been disposed of.</exception>
        /// <since_tizen> 4 </since_tizen>
        public static void GenerateImage(string message, QrConfiguration qrConfig,
                                         BarcodeImageConfiguration imageConfig, BarcodeGenerationConfiguration config)
        {
            if (qrConfig == null)
            {
                throw new ArgumentNullException(nameof(qrConfig));
            }

            if (config != null)
            {
                if (config.TextVisibility == Visibility.Visible)
                {
                    throw new NotSupportedException("Text can't be visible in QR.");
                }
            }

            GenerateImage(config, message, BarcodeType.QR, imageConfig, (int)qrConfig.Mode,
                          (int)qrConfig.ErrorCorrectionLevel, qrConfig.Version);
        }
Example #4
0
        private static void GenerateImage(BarcodeGenerationConfiguration config,
                                          string message, BarcodeType type, BarcodeImageConfiguration imageConfig,
                                          int qrMode, int qrEcc, int qrVersion)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (imageConfig == null)
            {
                throw new ArgumentNullException(nameof(imageConfig));
            }

            ValidationUtil.ValidateEnum(typeof(BarcodeType), type);

            InteropBarcode.GenerateImage(EngineConfiguration.GetHandle(config), message,
                                         imageConfig.Width, imageConfig.Height, type, qrMode, qrEcc, qrVersion,
                                         imageConfig.Path, imageConfig.Format).
            Validate("Failed to generate image");
        }
Example #5
0
 /// <summary>
 /// Generates a barcode image file with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
 /// </summary>
 /// <param name="message">The message to be encoded in the barcode.</param>
 /// <param name="type">Type of the barcode to be generated.</param>
 /// <param name="imageConfig">The <see cref="BarcodeImageConfiguration"/> that contains
 ///     information about the file to be generated.</param>
 /// <param name="config">The configuration of the barcode generator. This value can be null.</param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="message"/> is null.<br/>
 ///     -or-<br/>
 ///     <paramref name="imageConfig"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     <paramref name="message"/> is too long.<br/>
 ///     -or-<br/>
 ///     <paramref name="type"/> is <see cref="BarcodeType.QR"/>.<br/>
 ///     -or-<br/>
 ///     <paramref name="type"/> is invalid.<br/>
 ///     -or-<br/>
 ///     <paramref name="message"/> contains illegal characters.
 /// </exception>
 /// <exception cref="UnauthorizedAccessException">No permission to write a file.</exception>
 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
 /// <exception cref="ObjectDisposedException"><paramref name="config"/> already has been disposed of.</exception>
 /// <since_tizen> 4 </since_tizen>
 public static void GenerateImage(string message,
                                  BarcodeType type, BarcodeImageConfiguration imageConfig, BarcodeGenerationConfiguration config)
 {
     if (type == BarcodeType.QR)
     {
         throw new ArgumentException($"Invalid barcode type : {type}.");
     }
     GenerateImage(config, message, type, imageConfig, NoneQrMode, NoneErrorCorrection, 0);
 }