Sync with tizen 2.4 13/47713/1 accepted/tizen/mobile/20150909.140821 accepted/tizen/tv/20150909.140126 accepted/tizen/wearable/20150909.135145 submit/tizen/20150909.092813
authorTae-Young Chung <ty83.chung@samsung.com>
Tue, 8 Sep 2015 06:02:57 +0000 (15:02 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Tue, 8 Sep 2015 06:03:51 +0000 (15:03 +0900)
Change-Id: I7be7c55d9a92015bf99af7110c4d1ab3daf6fd2e
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
include/mv_barcode_detect.h
include/mv_barcode_generate.h
include/mv_common.h
media-vision-config.json
mv_barcode/barcode_generator/include/BarcodeGenerator.h
mv_barcode/barcode_generator/include/BarcodeOptions.h
mv_barcode/barcode_generator/src/BarcodeGenerator.cpp
mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp

index 77be222514f17940b3b0b6da099c6b6b28c54779..b3981b6611f9b674adb9d23a05632de1bf1fab33 100644 (file)
@@ -35,18 +35,7 @@ extern "C" {
  */
 
 /**
- * @brief Define MV_BARCODE_DETECT_ATTR_MODE to set mode attribute of the engine
- *        configuration.
- *
- * @since_tizen 2.4
- *
- * @see mv_barcode_detect_attr_mode_e
- */
-#define MV_BARCODE_DETECT_ATTR_MODE   "MV_BARCODE_DETECT_ATTR_MODE"    /**< Mode: 0-image, 1-video*/
-
-/**
- * @brief Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the
- *        engine configuration.
+ * @brief Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the engine configuration
  *
  * @since_tizen 2.4
  *
@@ -55,28 +44,17 @@ extern "C" {
 #define MV_BARCODE_DETECT_ATTR_TARGET "MV_BARCODE_DETECT_ATTR_TARGET"  /**< Target: 0-all, 1-1D, 2-2D*/
 
 /**
- * @brief Enumeration to mode attribute.
+ * @brief Enumeration to target attribute
  *
  * @since_tizen 2.4
  */
-typedef enum
-{
-    MV_BARCODE_DETECT_ATTR_MODE_IMAGE,    /**< Still image */
-    MV_BARCODE_DETECT_ATTR_MODE_VIDEO     /**< Continuous video */
-} mv_barcode_detect_attr_mode_e;
-
-/**
- * @brief Enumeration to target attribute.
- *
- * @since_tizen 2.4
- */
-typedef enum
-{
-    MV_BARCODE_DETECT_ATTR_TARGET_ALL,          /**< 1D and 2D */
-    MV_BARCODE_DETECT_ATTR_TARGET_1D_BARCODE,   /**< 1D barcode only */
-    MV_BARCODE_DETECT_ATTR_TARGET_2D_BARCODE,   /**< 2D barcode only */
+typedef enum {
+       MV_BARCODE_DETECT_ATTR_TARGET_ALL,          /**< 1D and 2D */
+       MV_BARCODE_DETECT_ATTR_TARGET_1D_BARCODE,   /**< 1D barcode only */
+       MV_BARCODE_DETECT_ATTR_TARGET_2D_BARCODE,   /**< 2D barcode only */
 } mv_barcode_detect_attr_target_e;
 
+
 /**
  * @brief Called when barcode detection is completed.
  * @details If no barcode is detected then the method will be called, barcodes
index 6d82709ca966803cd68b23d0d05e79e92a60cf38..1662525e0eafee3b4a7e7625f98f913df71f534e 100644 (file)
@@ -34,6 +34,30 @@ extern "C" {
  * @{
  */
 
+/**
+ * @brief Define MV_BARCODE_GENERATE_ATTR_TEXT to set text attribute
+          of the engine configuration
+ *
+ * @since_tizen 2.4
+ * @remarks This attribute is only available for 1D barcode generation
+ *
+ * @see mv_barcode_generate_attr_text_e
+ */
+#define MV_BARCODE_GENERATE_ATTR_TEXT "MV_BARCODE_GENERATE_ATTR_TEXT" /**< Text:
+                                                                    0-invisible,
+                                                                    1-visible */
+
+/**
+ * @brief Enumeration to text attribute
+ *
+ * @since_tizen 2.4
+ */
+typedef enum {
+    MV_BARCODE_GENERATE_ATTR_TEXT_INVISIBLE,   /**< Invisible */
+    MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE,     /**< Visible */
+} mv_barcode_generate_attr_text_e;
+
+
 /**
  * @brief Generates @ref mv_source_h with barcode image.
  * @details Pay attention that for EAN-8 and EAN-13 barcode types the barcode
@@ -42,6 +66,11 @@ extern "C" {
  * required to generate QR code with the input message length.
  *
  * @since_tizen 2.4
+ * @remarks If the text attribute of engine configuration is set to
+ *          MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE,
+ *          MEDIA_VISION_ERROR_INVALID_OPERATION will be return
+ *          when @a type is MV_BARCODE_QR
+ *
  * @param [in]  engine_cfg      The handle to the configuration of the engine
  * @param [in]  message         The message to be encoded in the barcode
  * @param [in]  type            Type of the barcode to be generated
@@ -62,6 +91,7 @@ extern "C" {
  * @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
  * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid data
  * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
  *
  * @pre Create an engine configuration handle by calling
  *      @ref mv_create_engine_config(), otherwise use NULL
@@ -85,6 +115,11 @@ int mv_barcode_generate_source(
  * required to generate QR code with the input message length.
  *
  * @since_tizen 2.4
+ * @remarks If the text attribute of engine configuration is set to
+ *          MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE,
+ *          MEDIA_VISION_ERROR_INVALID_OPERATION will be return
+ *          when @a type is MV_BARCODE_QR
+ *
  * @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
             if @a image_path is relevant to media storage.\n
             The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
@@ -113,6 +148,7 @@ int mv_barcode_generate_source(
  * @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid data
  * @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path
  * @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
  *
  * @pre Create an engine configuration handle by calling
  *      @ref mv_create_engine_config(), otherwise use NULL
index ff3a5e5a0cc4e32d62230f2ec4f6790933d8e2d1..f8eb83e23ac16858031691473c21c14f7f7de788 100644 (file)
@@ -439,8 +439,8 @@ int mv_engine_config_set_double_attribute(
  * @see mv_engine_config_set_double_attribute()
  * @see mv_engine_config_set_bool_attribute()
  * @see mv_engine_config_set_string_attribute()
- * @see mv_barcode_detect_attr_mode_e
  * @see mv_barcode_detect_attr_target_e
+ * @see mv_barcode_generate_attr_text_e
  */
 int mv_engine_config_set_int_attribute(
         mv_engine_config_h engine_cfg,
@@ -547,8 +547,8 @@ int mv_engine_config_get_double_attribute(
  * @see mv_engine_config_get_double_attribute()
  * @see mv_engine_config_get_bool_attribute()
  * @see mv_engine_config_get_string_attribute()
- * @see mv_barcode_detect_attr_mode_e
  * @see mv_barcode_detect_attr_target_e
+ * @see mv_barcode_generate_attr_text_e
  */
 int mv_engine_config_get_int_attribute(
         mv_engine_config_h engine_cfg,
index 902567e23d0a80567fa5ab1fbef74f5d837fd016..a3d6eeead6869295f9be3d0c4c7ebd3c5d145faf 100644 (file)
             "type"  : "integer",
             "value" : -1,
         },
-        {
-            "name" : "MV_BARCODE_DETECT_ATTR_MODE",
-            "type" : "integer",
-            "value" : 1,
+        {    "name"  : "MV_BARCODE_GENERATE_ATTR_TEXT",
+             "type"  : "integer",
+             "value" : 0,
         },
         {
             "name" : "MV_BARCODE_DETECT_ATTR_TARGET",
index 8640683c6ec17a7c16802d1e0b805474f333105b..40659aeaa99c458365793837eae5f5f4fd2ddf73 100644 (file)
@@ -54,6 +54,7 @@ public:
      * @param [in] encodingMode     Encoding mode (for QR codes only)
      * @param [in] correctionLevel  Error correction level (for QR codes only)
      * @param [in] qrVersion        QR code version (1 ~ 40, 0 for 1D barcodes)
+     * @param [in] showText         Show text or not
      * @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
      *         BarcodeError value otherwise
      */
@@ -66,7 +67,8 @@ public:
         BarcodeType type,
         BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
         BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
-        int qrVersion = 0);
+        int qrVersion = 0,
+        int showText = 0);
 
     /**
      * @brief This method generates Barcodes image buffer according to options.
@@ -81,6 +83,7 @@ public:
      * @param [in] encodingMode        Encoding mode (for QR codes only)
      * @param [in] correctionLevel     Error correction level (for QR codes only)
      * @param [in] qrVersion           QR code version (1 ~ 40, 0 for 1D barcodes)
+     * @param [in] showText            Show text or not
      * @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
      *         BarcodeError value otherwise
      */
@@ -93,7 +96,8 @@ public:
         BarcodeType type,
         BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
         BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
-        int qrVersion = 0);
+        int qrVersion = 0,
+        int showText = 0);
 };
 
 } /* Barcode */
index 4da3b90dd96e04144501a2d4a9155f0027283154..c6435500824cecd65c93caea3a2480c4318d3a87 100644 (file)
@@ -88,6 +88,17 @@ enum BarcodeImageFormat
     BARCODE_IMAGE_BMP
 };
 
+/**
+ * @brief The Barcode generation text option enumeration.
+ *
+ * @since_tizen 2.4
+ */
+enum BarcodeGenTextOpt
+{
+       BARCODE_GEN_TEXT_INVISIBLE,
+       BARCODE_GEN_TEXT_VISIBLE
+};
+
 /**
  * @brief The Barcode error enumeration.
  *
index 8e1d85dd6d17ad2bf56d53b4395d8af621474221..624a3f51acb86d1890eef325de4a93e34fd0c7d7 100644 (file)
@@ -74,6 +74,7 @@ int createBarcode(
         BarcodeQREncodingMode encodingMode,
         BarcodeQRErrorCorrectionLevel correctionLevel,
         int qrVersion,
+        int showText,
         zint_symbol *symbol)
 {
     // set input values
@@ -82,14 +83,20 @@ int createBarcode(
     symbol->option_1 = correctionLevel;
     symbol->option_2 = qrVersion;
     symbol->scale = 1;
+    symbol->show_hrt = showText;
 
     // set default values
-    std::strcpy(symbol->fgcolour, "000000");
-    std::strcpy(symbol->bgcolour, "ffffff");
+    std::strncpy(symbol->fgcolour, "000000", 10);
+    std::strncpy(symbol->bgcolour, "ffffff", 10);
     symbol->border_width = 1;
-    symbol->whitespace_width = 0;
     symbol->height = 50;
 
+    if (type == BARCODE_QR) {
+        symbol->whitespace_width = 0;
+    } else {
+        symbol->whitespace_width = 10;
+    }
+
     // create barcode
     const int rotationAngle = 0;
     int error = ZBarcode_Encode_and_Buffer(
@@ -195,16 +202,25 @@ int BarcodeGenerator::generateBarcodeToImage(
         BarcodeType type,
         BarcodeQREncodingMode encodingMode,
         BarcodeQRErrorCorrectionLevel correctionLevel,
-        int qrVersion)
+        int qrVersion,
+        int showText)
 {
     zint_symbol *symbol = ZBarcode_Create();
 
+    if(symbol == NULL)
+    {
+        LOGE("ZBarcode creation failed");
+
+        return BARCODE_ERROR_ENCODING_PROBLEM;
+    }
+
     int error = createBarcode(
                     message,
                     type,
                     encodingMode,
                     correctionLevel,
                     qrVersion,
+                    showText,
                     symbol);
 
     if (error != BARCODE_ERROR_NONE)
@@ -243,16 +259,25 @@ int BarcodeGenerator::generateBarcodeToBuffer(
         BarcodeType type,
         BarcodeQREncodingMode encodingMode,
         BarcodeQRErrorCorrectionLevel correctionLevel,
-        int qrVersion)
+        int qrVersion,
+        int showText)
 {
     zint_symbol *symbol = ZBarcode_Create();
 
+    if(symbol == NULL)
+    {
+        LOGE("ZBarcode creation failed");
+
+        return BARCODE_ERROR_ENCODING_PROBLEM;
+    }
+
     int error = createBarcode(
                     message,
                     type,
                     encodingMode,
                     correctionLevel,
                     qrVersion,
+                    showText,
                     symbol);
 
     if (error != BARCODE_ERROR_NONE)
index 1aa3034ca86181ff3e6dc8fcca35dec2bba1a330..19657d3e5d82477b4b7cb3baf3f53e5a17ab5dc2 100644 (file)
@@ -197,7 +197,7 @@ BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format)
 } /* anonymous namespace */
 
 int mv_barcode_generate_source_open(
-        mv_engine_config_h /*engine_cfg*/,
+        mv_engine_config_h engine_cfg,
         const char *message,
         mv_barcode_type_e type,
         mv_barcode_qr_mode_e qr_enc_mode,
@@ -231,6 +231,20 @@ int mv_barcode_generate_source_open(
     unsigned int imageHeight = 0u;
     unsigned int imageChannels = 0u;
 
+    int showText = 0;
+    error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
+    if (error != MEDIA_VISION_ERROR_NONE)
+    {
+        LOGW("mv_engine_config_get_int_attribute failed");
+        return error;
+    }
+
+    if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR)
+    {
+        LOGW("QR code generation with visible text is not supported");
+        return MEDIA_VISION_ERROR_INVALID_OPERATION;
+    }
+
     error = BarcodeGenerator::generateBarcodeToBuffer(
                     &imageBuffer,
                     &imageWidth,
@@ -240,7 +254,8 @@ int mv_barcode_generate_source_open(
                     convertBarcodeType(type),
                     convertEncodingMode(qr_enc_mode),
                     convertECC(qr_ecc),
-                    qr_version);
+                    qr_version,
+                    showText);
 
     if (error != BARCODE_ERROR_NONE)
     {
@@ -283,7 +298,7 @@ int mv_barcode_generate_source_open(
 
 
 int mv_barcode_generate_image_open(
-        mv_engine_config_h /*engine_cfg*/,
+        mv_engine_config_h engine_cfg,
         const char *message,
         int image_width,
         int image_height,
@@ -321,6 +336,20 @@ int mv_barcode_generate_image_open(
         }
     }
 
+    int showText = 0;
+    error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
+    if (error != MEDIA_VISION_ERROR_NONE)
+    {
+        LOGW("mv_engine_config_get_int_attribute failed");
+        return error;
+    }
+
+    if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR)
+    {
+        LOGW("QR code generation with visible text is not supported");
+        return MEDIA_VISION_ERROR_INVALID_OPERATION;
+    }
+
     error = BarcodeGenerator::generateBarcodeToImage(
                           std::string(image_path),
                           convertImageFormat(image_format),
@@ -330,7 +359,8 @@ int mv_barcode_generate_image_open(
                           convertBarcodeType(type),
                           convertEncodingMode(qr_enc_mode),
                           convertECC(qr_ecc),
-                          qr_version);
+                          qr_version,
+                          showText);
 
     if (error != BARCODE_ERROR_NONE)
     {