1-visible */
/**
+ * @brief Defines MV_BARCODE_GENERATE_ATTR_COLOR_FRONT to set
+ Barcode's foreground color attribute of the engine configuration.
+ *
+ * @since_tizen 3.0
+ * @remarks This attribute represents RGB color as a hex triplet with six digits.
+ */
+#define MV_BARCODE_GENERATE_ATTR_COLOR_FRONT "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT"
+
+/**
+ * @brief Defines MV_BARCODE_GENERATE_ATTR_COLOR_BACK to set
+ Barcode's background color attribute of the engine configuration.
+ *
+ * @since_tizen 3.0
+ * @remarks This attribute represents RGB color as a hex triplet with six digits.
+ */
+#define MV_BARCODE_GENERATE_ATTR_COLOR_BACK "MV_BARCODE_GENERATE_ATTR_COLOR_BACK"
+
+/**
* @brief Enumeration to text attribute
*
* @since_tizen @if MOBILE 2.4 @else 3.0 @endif
"value" : 0
},
{
+ "name" : "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT",
+ "type" : "string",
+ "value" : "000000"
+ },
+ {
+ "name" : "MV_BARCODE_GENERATE_ATTR_COLOR_BACK",
+ "type" : "string",
+ "value" : "ffffff"
+ },
+ {
"name" : "MV_BARCODE_DETECT_ATTR_TARGET",
"type" : "integer",
"value" : 0
* @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
+ * @param [in] fgcolour Foreground colour of barcode
+ * @param [in] bgcolour Background colour of barcode
* @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
* BarcodeError value otherwise
*/
BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
int qrVersion = 0,
- int showText = 0);
+ int showText = 0,
+ char *fgcolour = NULL,
+ char *bgcolur = NULL);
/**
* @brief This method generates Barcodes image buffer according to options.
* @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
+ * @param [in] fgcolour Foreground colour of barcode
+ * @param [in] bgcolour Background colour of barcode
* @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
* BarcodeError value otherwise
*/
BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
int qrVersion = 0,
- int showText = 0);
+ int showText = 0,
+ char *fgcolour = NULL,
+ char *bgcolur = NULL);
};
} /* Barcode */
BarcodeQRErrorCorrectionLevel correctionLevel,
int qrVersion,
int showText,
+ char *fgcolour,
+ char *bgcolour,
zint_symbol *symbol)
{
/* set input values */
symbol->show_hrt = showText;
/* set default values */
- std::strncpy(symbol->fgcolour, "000000", 10);
- std::strncpy(symbol->bgcolour, "ffffff", 10);
+ if (fgcolour) {
+ std::strncpy(symbol->fgcolour, fgcolour, 10);
+ if (strlen(fgcolour) > 9) {
+ symbol->fgcolour[9] = '\0';
+ }
+ } else {
+ std::strncpy(symbol->fgcolour, "000000", 10);
+ }
+
+ if (bgcolour) {
+ std::strncpy(symbol->bgcolour, bgcolour, 10);
+ if (strlen(fgcolour) > 9) {
+ symbol->fgcolour[9] = '\0';
+ }
+ } else {
+ std::strncpy(symbol->bgcolour, "ffffff", 10);
+ }
+
+ LOGI("Check colors: front %s, back %s", symbol->fgcolour, symbol->bgcolour);
+
symbol->border_width = 1;
symbol->height = 50;
BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel,
int qrVersion,
- int showText)
+ int showText,
+ char *fgcolour,
+ char *bgcolour)
{
zint_symbol *symbol = ZBarcode_Create();
correctionLevel,
qrVersion,
showText,
+ fgcolour,
+ bgcolour,
symbol);
if (error != BARCODE_ERROR_NONE) {
BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel,
int qrVersion,
- int showText)
+ int showText,
+ char *fgcolour,
+ char *bgcolour)
{
zint_symbol *symbol = ZBarcode_Create();
correctionLevel,
qrVersion,
showText,
+ fgcolour,
+ bgcolour,
symbol);
if (error != BARCODE_ERROR_NONE) {
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;
- }
+ char value;
+ char *fgcolour = NULL;
+ char *bgcolour = NULL;
+
+ if (engine_cfg != NULL) {
+ 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;
+ }
+
+ /* set color value */
+ error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT", &fgcolour);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ if (fgcolour) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
- 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;
+ LOGW("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
+
+ error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_BACK", &bgcolour);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ if (bgcolour) {
+ delete [] bgcolour;
+ bgcolour = NULL;
+ }
+
+ if (fgcolour) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
+
+ LOGW("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
}
+ /*
+ The input colorspace is RGB but the generators' is BGR.
+ Replace the value of R with that of B
+ */
+ value = fgcolour[0];
+ fgcolour[0] = fgcolour[4];
+ fgcolour[4] = value;
+
+ value = fgcolour[1];
+ fgcolour[1] = fgcolour[5];
+ fgcolour[5] = value;
+
+ value = bgcolour[0];
+ bgcolour[0] = bgcolour[4];
+ bgcolour[4] = value;
+
+ value = bgcolour[1];
+ bgcolour[1] = bgcolour[5];
+ bgcolour[5] = value;
+
error = BarcodeGenerator::generateBarcodeToBuffer(
&imageBuffer,
&imageWidth,
convertEncodingMode(qr_enc_mode),
convertECC(qr_ecc),
qr_version,
- showText);
+ showText,
+ fgcolour,
+ bgcolour);
+
+ if (fgcolour != NULL) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
+
+ if (bgcolour != NULL) {
+ delete [] bgcolour;
+ bgcolour = NULL;
+ }
if (error != BARCODE_ERROR_NONE) {
LOGE("Barcode generation to the buffer failed");
}
int showText = 0;
+ char value;
+ char *fgcolour = NULL;
+ char *bgcolour = NULL;
if (engine_cfg != NULL) {
+ /* set visible text attribute */
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");
LOGW("QR code generation with visible text is not supported");
return MEDIA_VISION_ERROR_INVALID_OPERATION;
}
+
+ /* set color value */
+ error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_FRONT", &fgcolour);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ if (fgcolour) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
+
+ LOGW("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
+
+ error = mv_engine_config_get_string_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_COLOR_BACK", &bgcolour);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ if (bgcolour) {
+ delete [] bgcolour;
+ bgcolour = NULL;
+ }
+
+ if (fgcolour) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
+
+ LOGW("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
}
+ /*
+ The input colorspace is RGB but the generators' is BGR.
+ Replace the value of R with that of B
+ */
+ value = fgcolour[0];
+ fgcolour[0] = fgcolour[4];
+ fgcolour[4] = value;
+
+ value = fgcolour[1];
+ fgcolour[1] = fgcolour[5];
+ fgcolour[5] = value;
+
+ value = bgcolour[0];
+ bgcolour[0] = bgcolour[4];
+ bgcolour[4] = value;
+
+ value = bgcolour[1];
+ bgcolour[1] = bgcolour[5];
+ bgcolour[5] = value;
+
error = BarcodeGenerator::generateBarcodeToImage(
std::string(image_path),
convertImageFormat(image_format),
convertEncodingMode(qr_enc_mode),
convertECC(qr_ecc),
qr_version,
- showText);
+ showText,
+ fgcolour,
+ bgcolour);
+
+ if (fgcolour != NULL) {
+ delete [] fgcolour;
+ fgcolour = NULL;
+ }
+
+ if (bgcolour != NULL) {
+ delete [] bgcolour;
+ bgcolour = NULL;
+ }
if (error != BARCODE_ERROR_NONE) {
LOGE("Barcode generation to the image file failed");
Name: capi-media-vision
Summary: Media Vision library for Tizen Native API
-Version: 0.3.12
+Version: 0.3.13
Release: 0
Group: Multimedia/Framework
License: Apache-2.0 and BSD-2.0
mv_barcode_type_e type;
mv_barcode_qr_ecc_e ecc;
mv_barcode_qr_mode_e mode;
+ int is_hrt;
int version;
size_t width;
size_t height;
char *file_name;
char *out_file_name;
unsigned char *out_buffer_ptr;
+ char *front_color;
+ char *back_color;
} barcode_model_s;
typedef enum {
if (model.message == NULL ||
model.file_name == NULL) {
MEDIA_VISION_FUNCTION_LEAVE();
+
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
LOGI("Call the mv_barcode_generate_image() function");
- const int err = mv_barcode_generate_image(
- NULL,
+ mv_engine_config_h mv_engine_config;
+ int err = mv_create_engine_config(&mv_engine_config);
+
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occurred during creating the media engine "
+ "config: %i\n", err);
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return err;
+ }
+
+ err = mv_engine_config_set_int_attribute(mv_engine_config,
+ MV_BARCODE_GENERATE_ATTR_TEXT,
+ model.is_hrt);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occured during set integer attribute to "
+ "media engine config: %i\n", err);
+ }
+
+ err = mv_engine_config_set_string_attribute(mv_engine_config,
+ MV_BARCODE_GENERATE_ATTR_COLOR_FRONT,
+ model.front_color);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occured during set string attribute to "
+ "media engine config: %i\n", err);
+ }
+
+ err = mv_engine_config_set_string_attribute(mv_engine_config,
+ MV_BARCODE_GENERATE_ATTR_COLOR_BACK,
+ model.back_color);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occured during set string attribute to "
+ "media engine config: %i\n", err);
+ }
+
+ err = mv_barcode_generate_image(
+ mv_engine_config,
model.message,
model.width,
model.height,
MEDIA_VISION_FUNCTION_LEAVE();
+ int err2 = mv_destroy_engine_config(mv_engine_config);
+ if (MEDIA_VISION_ERROR_NONE != err2) {
+ printf("ERROR: Errors were occurred during destroying the media engine "
+ "config: %i\n", err2);
+ }
+
return err;
}
printf("ERROR: Error occurred when trying to create Media Vision "
"source. Error code: %i\n", err);
- MEDIA_VISION_FUNCTION_LEAVE();
+ MEDIA_VISION_FUNCTION_LEAVE();
- return err;
+ return err;
}
LOGI("mv_source_h creation finished");
"config: %i\n", err);
}
+ err = mv_engine_config_set_string_attribute(mv_engine_config,
+ MV_BARCODE_GENERATE_ATTR_COLOR_FRONT,
+ model.front_color);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occured during set string attribute to "
+ "media engine config: %i\n", err);
+ }
+
+ err = mv_engine_config_set_string_attribute(mv_engine_config,
+ MV_BARCODE_GENERATE_ATTR_COLOR_BACK,
+ model.back_color);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occured during set string attribute to "
+ "media engine config: %i\n", err);
+ }
+
err = mv_barcode_generate_source(
mv_engine_config,
model.message,
return selected_ecc;
}
+int select_attribute_text(void)
+{
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int sel_opt = 0;
+ int selected_attr = 0;
+ const int options[2] = { 1, 2 };
+ const char *names[2] = { "Invisible", "Visible" };
+
+ while (sel_opt == 0) {
+ sel_opt = show_menu("Select attribute text", options, names, 2);
+ switch (sel_opt) {
+ case 1:
+ selected_attr = 0;
+ break;
+ case 2:
+ selected_attr = 1;
+ break;
+ default:
+ sel_opt = 0;
+ break;
+ }
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return selected_attr;
+}
+
int select_version(void)
{
MEDIA_VISION_FUNCTION_ENTER();
MV_BARCODE_UNDEFINED,
MV_BARCODE_QR_ECC_UNAVAILABLE,
MV_BARCODE_QR_MODE_UNAVAILABLE,
+ 0,
0, 0, 0,
MV_BARCODE_IMAGE_FORMAT_PNG,
MEDIA_VISION_COLORSPACE_INVALID,
- NULL, NULL, NULL, NULL };
+ NULL, NULL, NULL, NULL, NULL, NULL };
while (input_string("Input file name to be analyzed:", 1024, &(detect_model.file_name)) == -1)
printf("Incorrect input! Try again.\n");
MV_BARCODE_UNDEFINED,
MV_BARCODE_QR_ECC_UNAVAILABLE,
MV_BARCODE_QR_MODE_UNAVAILABLE,
+ 0,
0, 0, 0,
MV_BARCODE_IMAGE_FORMAT_PNG,
MEDIA_VISION_COLORSPACE_INVALID,
- NULL, NULL, NULL, NULL };
+ NULL, NULL, NULL, NULL, NULL, NULL };
generation_fcn_e gen_fcn = select_gen_function();
generate_model.type = select_type();
LOGI("Barcode version has been selected");
}
+ if (generate_model.type != MV_BARCODE_QR) {
+ generate_model.is_hrt = select_attribute_text();
+ LOGI("Barcode readable text attribute has been selected");
+ }
+
if (gen_fcn == MV_TS_GENERATE_TO_IMAGE_FCN) {
generate_model.out_image_format = select_file_format();
LOGI("Barcode output image format has been selected");
LOGI("Barcode output file name has been specified");
+ while (input_string("Input foreground color (ex:black is 000000):", 1024, &generate_model.front_color) == -1)
+ printf("Incorrect input! Try again.\n");
+
+ LOGI("Foreground color is %s", generate_model.front_color);
+
+ while (input_string("Input background color (ex:white is ffffff):", 1024, &generate_model.back_color) == -1)
+ printf("Incorrect input! Try again.\n");
+
+ LOGI("Background color is %s", generate_model.back_color);
+
if (gen_fcn == MV_TS_GENERATE_TO_IMAGE_FCN) {
while (input_size("Input image width:", 10000, &generate_model.width) == -1)
printf("Incorrect input! Try again.\n");
if (generate_model.file_name != NULL)
free(generate_model.file_name);
+ if (generate_model.front_color != NULL)
+ free(generate_model.front_color);
+
+ if (generate_model.back_color != NULL)
+ free(generate_model.back_color);
+
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Barcode generation failed with error code (0x%08x)", err);
printf("ERROR: Errors were occurred during barcode generation!!!\n");