From 40f88064eb815eb8255348c8245f7dc1220a2152 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Thu, 4 May 2023 17:27:59 +0900 Subject: [PATCH] [MediaVision] Add internal APIs for Design QR feature (#5241) * [MediaVision] Add internal APIs for Design QR feature --- .../MediaVision/BarcodeGenerationConfiguration.cs | 48 ++++++++++++++- .../MediaVision/BarcodeGenerator.cs | 49 +++++++++++++-- .../MediaVision/QrConfiguration.cs | 69 ++++++++++++++++++++++ src/Tizen.Multimedia.Vision/MediaVision/QrShape.cs | 44 ++++++++++++++ 4 files changed, 203 insertions(+), 7 deletions(-) create mode 100755 src/Tizen.Multimedia.Vision/MediaVision/QrShape.cs diff --git a/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerationConfiguration.cs b/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerationConfiguration.cs index aaf7f79..7ee7bc0 100755 --- a/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerationConfiguration.cs +++ b/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerationConfiguration.cs @@ -29,6 +29,9 @@ namespace Tizen.Multimedia.Vision 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"; /// /// Initializes a new instance of the class. @@ -43,7 +46,7 @@ namespace Tizen.Multimedia.Vision /// Gets or sets the text visibility of the barcode to be generated. /// /// is not valid. - /// The already has been disposed of. + /// The already has been disposed. /// 4 public Visibility TextVisibility { @@ -67,7 +70,7 @@ namespace Tizen.Multimedia.Vision /// /// The alpha value of the color will be ignored. /// - /// The already has been disposed of. + /// The already has been disposed. /// 4 public Color ForegroundColor { @@ -90,7 +93,7 @@ namespace Tizen.Multimedia.Vision /// /// The alpha value of the color will be ignored. /// - /// The already has been disposed of. + /// The already has been disposed. /// 4 public Color BackgroundColor { @@ -104,5 +107,44 @@ namespace Tizen.Multimedia.Vision _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); + } + } } } diff --git a/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerator.cs b/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerator.cs index 03038bb..061781d 100755 --- a/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerator.cs +++ b/src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerator.cs @@ -31,6 +31,20 @@ namespace Tizen.Multimedia.Vision 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) { @@ -59,6 +73,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a QR image with the specified message. /// + /// http://tizen.org/feature/vision.barcode_generation /// The message to be encoded in the barcode. /// The instance. /// containing the generated QR image. @@ -83,6 +98,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a QR image with the specified message with . /// + /// http://tizen.org/feature/vision.barcode_generation /// The message to be encoded in the barcode. /// The instance. /// The configuration of the barcode generator. This value can be null. @@ -124,6 +140,16 @@ namespace Tizen.Multimedia.Vision throw new NotSupportedException("Text can't be visible in QR."); } } + else + { + if (qrConfig.DataShape != QrShape.Rectangular || qrConfig.FinderShape != QrShape.Rectangular || + qrConfig.EmbedImagePath != null) + { + config = new BarcodeGenerationConfiguration(); + } + } + + SetDesignQrOptions(qrConfig, config); return GenerateSource(config, message, BarcodeType.QR, (int)qrConfig.Mode, (int)qrConfig.ErrorCorrectionLevel, qrConfig.Version); @@ -155,6 +181,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a barcode image with the specified message and . /// + /// http://tizen.org/feature/vision.barcode_generation /// The message to be encoded in the barcode. /// Type of the barcode to be generated. /// The configuration of the barcode generator. This value can be null. @@ -208,6 +235,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a QR image file with the specified message. /// + /// http://tizen.org/feature/vision.barcode_generation /// /// must be , /// because the text visibility is not supported in the QR code. @@ -227,7 +255,7 @@ namespace Tizen.Multimedia.Vision /// -or-
/// contains characters which are illegal by the . /// - /// No permission to write a file. + /// No permission to access a file. /// The feature is not supported. /// /// 4 @@ -240,6 +268,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a QR image file with the specified message and . /// + /// http://tizen.org/feature/vision.barcode_generation /// /// must be , /// because the text visibility is not supported in the QR code. @@ -261,7 +290,7 @@ namespace Tizen.Multimedia.Vision /// -or-
/// contains characters which are illegal by the . /// - /// No permission to write a file. + /// No permission to access a file. /// /// The feature is not supported.
/// -or-
@@ -284,6 +313,16 @@ namespace Tizen.Multimedia.Vision throw new NotSupportedException("Text can't be visible in QR."); } } + else + { + if (qrConfig.DataShape != QrShape.Rectangular || qrConfig.FinderShape != QrShape.Rectangular || + qrConfig.EmbedImagePath != null) + { + config = new BarcodeGenerationConfiguration(); + } + } + + SetDesignQrOptions(qrConfig, config); GenerateImage(config, message, BarcodeType.QR, imageConfig, (int)qrConfig.Mode, (int)qrConfig.ErrorCorrectionLevel, qrConfig.Version); @@ -292,6 +331,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a barcode image file with the specified message. /// + /// http://tizen.org/feature/vision.barcode_generation /// The message to be encoded in the barcode. /// Type of the barcode to be generated. /// The that contains @@ -310,7 +350,7 @@ namespace Tizen.Multimedia.Vision /// -or-
/// contains illegal characters. ///
- /// No permission to write a file. + /// No permission to access a file. /// The feature is not supported. /// 4 public static void GenerateImage(string message, BarcodeType type, BarcodeImageConfiguration imageConfig) @@ -321,6 +361,7 @@ namespace Tizen.Multimedia.Vision /// /// Generates a barcode image file with the specified message and . /// + /// http://tizen.org/feature/vision.barcode_generation /// The message to be encoded in the barcode. /// Type of the barcode to be generated. /// The that contains @@ -340,7 +381,7 @@ namespace Tizen.Multimedia.Vision /// -or-
/// contains illegal characters. /// - /// No permission to write a file. + /// No permission to access a file. /// The feature is not supported. /// already has been disposed of. /// 4 diff --git a/src/Tizen.Multimedia.Vision/MediaVision/QrConfiguration.cs b/src/Tizen.Multimedia.Vision/MediaVision/QrConfiguration.cs index cd070a7..896f2de 100755 --- a/src/Tizen.Multimedia.Vision/MediaVision/QrConfiguration.cs +++ b/src/Tizen.Multimedia.Vision/MediaVision/QrConfiguration.cs @@ -15,6 +15,7 @@ */ using System; +using System.ComponentModel; namespace Tizen.Multimedia.Vision { @@ -24,6 +25,10 @@ namespace Tizen.Multimedia.Vision /// 4 public class QrConfiguration { + private string _embedImagePath; + private QrShape _dataShape = QrShape.Rectangular; + private QrShape _finderShape = QrShape.Rectangular; + /// /// Initializes a new instance of the class. /// @@ -78,5 +83,69 @@ namespace Tizen.Multimedia.Vision /// /// 4 public int Version { get; } + + /// + /// Gets or sets the embed image absolute path of the Design QR code. + /// + /// + /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.
+ /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage. + ///
+ /// is null. + /// is zero-length string. + [EditorBrowsable(EditorBrowsableState.Never)] + public string EmbedImagePath + { + get + { + return _embedImagePath; + } + set + { + ValidationUtil.ValidateIsNullOrEmpty(value, nameof(value)); + + _embedImagePath = value; + } + } + + /// + /// Gets or sets the data shape of the Design QR code. + /// + /// The default value is . + /// is not valid. + [EditorBrowsable(EditorBrowsableState.Never)] + public QrShape DataShape + { + get + { + return _dataShape; + } + set + { + ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value)); + + _dataShape = value; + } + } + + /// + /// Gets or sets the finder shape of the Design QR code. + /// + /// The default value is . + /// is not valid. + [EditorBrowsable(EditorBrowsableState.Never)] + public QrShape FinderShape + { + get + { + return _finderShape; + } + set + { + ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value)); + + _finderShape = value; + } + } } } diff --git a/src/Tizen.Multimedia.Vision/MediaVision/QrShape.cs b/src/Tizen.Multimedia.Vision/MediaVision/QrShape.cs new file mode 100755 index 0000000..c5d1c0c --- /dev/null +++ b/src/Tizen.Multimedia.Vision/MediaVision/QrShape.cs @@ -0,0 +1,44 @@ +/* + * 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. + */ + +using System.ComponentModel; + +namespace Tizen.Multimedia.Vision +{ + /// + /// Specifies the shape of QR code. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum QrShape + { + /// + /// Rectangular. + /// + Rectangular, + + /// + /// Rectangular with rounded corners. + /// + RoundRectangular, + + /// + /// Circle. + /// + Circle + } +} -- 2.7.4