private const string KeyTextAttr = "MV_BARCODE_GENERATE_ATTR_TEXT";
private const string KeyForegroundColorAttr = "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT";
private const string KeyBackgroundColorAttr = "MV_BARCODE_GENERATE_ATTR_COLOR_BACK";
+ private const string KeyEmbedImageAbsolutePathAttr = "MV_BARCODE_GENERATE_ATTR_EMBED_IMG_PATH";
+ private const string KeyDataShapeAttr = "MV_BARCODE_GENERATE_ATTR_DATA_SHAPE";
+ private const string KeyFinderShapeAttr = "MV_BARCODE_GENERATE_ATTR_FINDER_SHAPE";
/// <summary>
/// Initializes a new instance of the <see cref="BarcodeGenerationConfiguration"/> class.
/// Gets or sets the text visibility of the barcode to be generated.
/// </summary>
/// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
- /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed of.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed.</exception>
/// <since_tizen> 4 </since_tizen>
public Visibility TextVisibility
{
/// <remarks>
/// The alpha value of the color will be ignored.
/// </remarks>
- /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed of.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed.</exception>
/// <since_tizen> 4 </since_tizen>
public Color ForegroundColor
{
/// <remarks>
/// The alpha value of the color will be ignored.
/// </remarks>
- /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed of.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="BarcodeGenerationConfiguration"/> already has been disposed.</exception>
/// <since_tizen> 4 </since_tizen>
public Color BackgroundColor
{
_backgroundColor = value;
}
}
+
+ internal string EmbedImagePath
+ {
+ get
+ {
+ return GetString(KeyEmbedImageAbsolutePathAttr);
+ }
+ set
+ {
+ // Validation is already checked in QrConfiguration.
+ Set(KeyEmbedImageAbsolutePathAttr, value);
+ }
+ }
+
+ internal QrShape DataShape
+ {
+ get
+ {
+ return (QrShape)GetInt(KeyDataShapeAttr);
+ }
+ set
+ {
+ // Validation is already checked in QrConfiguration.
+ Set(KeyDataShapeAttr, (int)value);
+ }
+ }
+
+ internal QrShape FinderShape
+ {
+ get
+ {
+ return (QrShape)GetInt(KeyFinderShapeAttr);
+ }
+ set
+ {
+ // Validation is already checked in QrConfiguration.
+ Set(KeyFinderShapeAttr, (int)value);
+ }
+ }
}
}
private const int NoneErrorCorrection = (int)ErrorCorrectionLevel.High + 1;
private const int NoneQrMode = (int)QrMode.Utf8 + 1;
+ private static void SetDesignQrOptions(QrConfiguration qrConfig, BarcodeGenerationConfiguration config)
+ {
+ if (config != null && qrConfig != null)
+ {
+ if (qrConfig.EmbedImagePath != null)
+ {
+ config.EmbedImagePath = qrConfig.EmbedImagePath;
+ }
+
+ config.DataShape = qrConfig.DataShape;
+ config.FinderShape = qrConfig.FinderShape;
+ }
+ }
+
private static MediaVisionSource GenerateSource(BarcodeGenerationConfiguration config,
string message, BarcodeType type, int qrMode, int qrEcc, int qrVersion)
{
/// <summary>
/// Generates a QR image with the specified message.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <param name="message">The message to be encoded in the barcode.</param>
/// <param name="qrConfig">The <see cref="QrConfiguration"/> instance.</param>
/// <returns><see cref="MediaVisionSource"/> containing the generated QR image.</returns>
/// <summary>
/// Generates a QR image with the specified message with <see cref="BarcodeGenerationConfiguration"/>.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <param name="message">The message to be encoded in the barcode.</param>
/// <param name="qrConfig">The <see cref="QrConfiguration"/> instance.</param>
/// <param name="config">The configuration of the barcode generator. This value can be null.</param>
throw new NotSupportedException("Text can't be visible in QR.");
}
}
+ else
+ {
+ if (qrConfig.DataShape != QrShape.Rectangular || qrConfig.FinderShape != QrShape.Rectangular)
+ {
+ config = new BarcodeGenerationConfiguration();
+
+ SetDesignQrOptions(qrConfig, config);
+ }
+ }
return GenerateSource(config, message, BarcodeType.QR, (int)qrConfig.Mode,
(int)qrConfig.ErrorCorrectionLevel, qrConfig.Version);
/// <summary>
/// Generates a barcode image with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <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>
/// <summary>
/// Generates a QR image file with the specified message.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <remarks>
/// <see cref="BarcodeGenerationConfiguration.TextVisibility"/> must be <see cref="Visibility.Invisible"/>,
/// because the text visibility is not supported in the QR code.
/// -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="UnauthorizedAccessException">No permission to access a file.</exception>
/// <exception cref="NotSupportedException">The feature is not supported.</exception>
/// <seealso cref="QrMode"/>
/// <since_tizen> 4 </since_tizen>
/// <summary>
/// Generates a QR image file with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <remarks>
/// <see cref="BarcodeGenerationConfiguration.TextVisibility"/> must be <see cref="Visibility.Invisible"/>,
/// because the text visibility is not supported in the QR code.
/// -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="UnauthorizedAccessException">No permission to access a file.</exception>
/// <exception cref="NotSupportedException">
/// The feature is not supported.<br/>
/// -or-<br/>
throw new NotSupportedException("Text can't be visible in QR.");
}
}
+ else
+ {
+ if (qrConfig.DataShape != QrShape.Rectangular || qrConfig.FinderShape != QrShape.Rectangular)
+ {
+ config = new BarcodeGenerationConfiguration();
+
+ SetDesignQrOptions(qrConfig, config);
+ }
+ }
GenerateImage(config, message, BarcodeType.QR, imageConfig, (int)qrConfig.Mode,
(int)qrConfig.ErrorCorrectionLevel, qrConfig.Version);
/// <summary>
/// Generates a barcode image file with the specified message.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <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
/// -or-<br/>
/// <paramref name="message"/> contains illegal characters.
/// </exception>
- /// <exception cref="UnauthorizedAccessException">No permission to write a file.</exception>
+ /// <exception cref="UnauthorizedAccessException">No permission to access a file.</exception>
/// <exception cref="NotSupportedException">The feature is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
public static void GenerateImage(string message, BarcodeType type, BarcodeImageConfiguration imageConfig)
/// <summary>
/// Generates a barcode image file with the specified message and <see cref="BarcodeGenerationConfiguration"/>.
/// </summary>
+ /// <feature>http://tizen.org/feature/vision.barcode_generation</feature>
/// <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
/// -or-<br/>
/// <paramref name="message"/> contains illegal characters.
/// </exception>
- /// <exception cref="UnauthorizedAccessException">No permission to write a file.</exception>
+ /// <exception cref="UnauthorizedAccessException">No permission to access 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>
/// <since_tizen> 4 </since_tizen>
public class QrConfiguration
{
+ private string _embedImagePath;
+ private QrShape _dataShape = QrShape.Rectangular;
+ private QrShape _finderShape = QrShape.Rectangular;
+
/// <summary>
/// Initializes a new instance of the <see cref="QrConfiguration"/> class.
/// </summary>
/// </summary>
/// <since_tizen> 4 </since_tizen>
public int Version { get; }
+
+ /// <summary>
+ /// Gets or sets the embed image absolute path of the Design QR code.
+ /// </summary>
+ /// <remarks>
+ /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.<br/>
+ /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage.
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
+ /// <exception cref="ArgumentException"><paramref name="value"/> is zero-length string.</exception>
+ /// <since_tizen> 11 </since_tizen>
+ public string EmbedImagePath
+ {
+ get
+ {
+ return _embedImagePath;
+ }
+ set
+ {
+ ValidationUtil.ValidateIsNullOrEmpty(value, nameof(value));
+
+ _embedImagePath = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the data shape of the Design QR code.
+ /// </summary>
+ /// <remarks>The default value is <see cref="QrShape.Rectangular"/>.</remarks>
+ /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
+ /// <since_tizen> 11 </since_tizen>
+ public QrShape DataShape
+ {
+ get
+ {
+ return _dataShape;
+ }
+ set
+ {
+ ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value));
+
+ _dataShape = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the finder shape of the Design QR code.
+ /// </summary>
+ /// <remarks>The default value is <see cref="QrShape.Rectangular"/>.</remarks>
+ /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
+ /// <since_tizen> 11 </since_tizen>
+ public QrShape FinderShape
+ {
+ get
+ {
+ return _finderShape;
+ }
+ set
+ {
+ ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value));
+
+ _finderShape = value;
+ }
+ }
}
}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Multimedia.Vision
+{
+ /// <summary>
+ /// Specifies the shape of QR code.
+ /// </summary>
+ /// <seealso cref="QrConfiguration.DataShape"/>
+ /// <seealso cref="QrConfiguration.FinderShape"/>
+ /// <since_tizen> 11 </since_tizen>
+ public enum QrShape
+ {
+ /// <summary>
+ /// Rectangular.
+ /// </summary>
+ Rectangular,
+
+ /// <summary>
+ /// Rectangular with rounded corners.
+ /// </summary>
+ RoundRectangular,
+
+ /// <summary>
+ /// Circle.
+ /// </summary>
+ Circle
+ }
+}