C-interface: return images as base64.
the build was successful
Details
the build was successful
Details
I couldn't figure out how to return them as MagickWand, maybe I can't mix Magick++ with MagickWand.
This commit is contained in:
parent
988eaf406c
commit
7d89f416e8
|
@ -23,7 +23,8 @@
|
|||
#include "debug.hpp"
|
||||
#include "identiconpp_c.h"
|
||||
|
||||
std::unique_ptr<Identiconpp> identicon;
|
||||
static std::unique_ptr<Identiconpp> identicon;
|
||||
static string base64;
|
||||
|
||||
bool identiconpp_setup(const uint8_t columns, const uint8_t rows,
|
||||
identiconpp_algorithm type,
|
||||
|
@ -72,11 +73,19 @@ bool identiconpp_setup(const uint8_t columns, const uint8_t rows,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool identiconpp_generate(MagickWand *wand,
|
||||
const char digest[], const uint16_t width)
|
||||
uint64_t identiconpp_generate(const char magick[],
|
||||
const char digest[], const uint16_t width)
|
||||
{
|
||||
Magick::Image img = identicon->generate(digest, width);
|
||||
Magick::Blob blob;
|
||||
img.magick(magick);
|
||||
img.write(&blob);
|
||||
MagickReadImageBlob(wand, blob.data(), blob.length());
|
||||
base64 = blob.base64();
|
||||
|
||||
return blob.base64().length();
|
||||
}
|
||||
|
||||
const char *identiconpp_base64()
|
||||
{
|
||||
return base64.c_str();
|
||||
}
|
||||
|
|
|
@ -25,8 +25,18 @@ extern "C"
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <MagickWand/MagickWand.h>
|
||||
|
||||
/*!
|
||||
* @example example.c
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief C interface for identiconpp.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief List of identicon algorithms
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
identiconpp_ltr_symmetric,
|
||||
|
@ -34,14 +44,38 @@ extern "C"
|
|||
identiconpp_sigil
|
||||
} identiconpp_algorithm;
|
||||
|
||||
/*!
|
||||
* @brief Setup identicon parameters.
|
||||
*
|
||||
* @param columns Number of columns
|
||||
* @param rows Number of rows
|
||||
* @param type The algorithm to use
|
||||
* @param background Background color, hexadecimal, rrggbbaa
|
||||
* @param foreground Array of foreground colors
|
||||
* @param foreground_len Length of the array of foreground colors
|
||||
* @param padding Padding in pixels { left & right, top & down }
|
||||
*
|
||||
* @return { description_of_the_return_value }
|
||||
*/
|
||||
bool identiconpp_setup(const uint8_t columns, const uint8_t rows,
|
||||
identiconpp_algorithm type,
|
||||
const char background[9],
|
||||
const char foreground[][9],
|
||||
const uint8_t foreground_len,
|
||||
const uint8_t padding[2]);
|
||||
bool identiconpp_generate(MagickWand *wand,
|
||||
const char digest[], const uint16_t width);
|
||||
|
||||
/*!
|
||||
* @brief Generates identicon from digest.
|
||||
*
|
||||
* @param magick See http://imagemagick.org/script/formats.php
|
||||
* @param digest The pre-computed digest
|
||||
* @param width The width of the identicon
|
||||
*
|
||||
* @return Length of the generated base64-string
|
||||
*/
|
||||
uint64_t identiconpp_generate(const char magick[],
|
||||
const char digest[], const uint16_t width);
|
||||
const char *identiconpp_base64();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue