std::string logo_path {};
};
-int write_buffer_to_img(zint_symbol *symbol, const BarcodeConfig &config);
-
-BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format);
-
-void swapBR(uint16_t *color);
-
-int mv_barcode_generate_symbol(zint_symbol *symbol, const BarcodeConfig &config);
+int symbol_to_source(zint_symbol *symbol, const BarcodeConfig &config, mv_source_h source);
+int symbol_to_image(zint_symbol *symbol, const BarcodeConfig &config);
} /* Barcode */
} /* MediaVision */
{
namespace Barcode
{
-BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format)
+static BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format)
{
BarcodeImageFormat imageFormat = BARCODE_IMAGE_PNG;
return error;
}
-int mv_barcode_generate_symbol(zint_symbol *symbol, const BarcodeConfig &config)
+static int mv_barcode_generate_symbol(zint_symbol *symbol, const BarcodeConfig &config)
{
int error = createBarcode(symbol, config);
cv::add(logoMat, image, image);
}
-int write_buffer_to_img(zint_symbol *symbol, const BarcodeConfig &config)
+static int write_buffer_to_img(zint_symbol *symbol, const BarcodeConfig &config)
{
std::string imageFileName = config.image_path;
/* find directory */
The input colorspace is RGB but the generators' is BGR.
Replace the value of R with that of B
*/
-void swapBR(uint16_t *color)
+static void swapBR(uint16_t *color)
{
std::swap(color[0], color[2]);
}
return MEDIA_VISION_ERROR_NONE;
}
+int symbol_to_source(zint_symbol *symbol, const BarcodeConfig &config, mv_source_h source)
+{
+ int ret = mv_barcode_generate_symbol(symbol, config);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_barcode_generate_symbol failed error : %d", ret);
+ return ret;
+ }
+
+ return mv_source_fill_by_buffer(source, (unsigned char *) symbol->bitmap,
+ symbol->bitmap_width * symbol->bitmap_height * 3, symbol->bitmap_width,
+ symbol->bitmap_height, MEDIA_VISION_COLORSPACE_RGB888);
+}
+
+int symbol_to_image(zint_symbol *symbol, const BarcodeConfig &config)
+{
+ int ret = mv_barcode_generate_symbol(symbol, config);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_barcode_generate_symbol failed error : %d", ret);
+ return ret;
+ }
+
+ return write_buffer_to_img(symbol, config);
+}
+
} /* Barcode */
} /* MediaVision */
LOGE("ZBarcode creation failed");
return MEDIA_VISION_ERROR_INTERNAL;
}
-
- ret = mv_barcode_generate_symbol(symbol, config);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- ZBarcode_Delete(symbol);
- return ret;
- }
-
- ret = mv_source_fill_by_buffer(image, (unsigned char *) symbol->bitmap,
- symbol->bitmap_width * symbol->bitmap_height * 3, symbol->bitmap_width,
- symbol->bitmap_height, MEDIA_VISION_COLORSPACE_RGB888);
+ ret = symbol_to_source(symbol, config, image);
ZBarcode_Delete(symbol);
MEDIA_VISION_FUNCTION_LEAVE();
return ret;
LOGE("ZBarcode creation failed");
return MEDIA_VISION_ERROR_INTERNAL;
}
-
- ret = mv_barcode_generate_symbol(symbol, config);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- ZBarcode_Delete(symbol);
- return ret;
- }
-
- ret = MediaVision::Barcode::write_buffer_to_img(symbol, config);
-
+ ret = symbol_to_image(symbol, config);
ZBarcode_Delete(symbol);
MEDIA_VISION_FUNCTION_LEAVE();
return ret;