2019-01-03 13:27:49 +01:00
|
|
|
/* This file is part of identiconpp.
|
|
|
|
* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-01-07 13:54:37 +01:00
|
|
|
#ifndef IDENTICONPP_C_H
|
|
|
|
#define IDENTICONPP_C_H
|
2019-01-03 13:27:49 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2019-01-04 17:36:10 +01:00
|
|
|
/*!
|
2019-01-04 20:35:28 +01:00
|
|
|
* @brief C interface for identiconpp.
|
|
|
|
* @file identiconpp_c.h
|
2019-01-04 17:36:10 +01:00
|
|
|
* @example example.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief List of identicon algorithms
|
|
|
|
*/
|
2019-01-03 13:27:49 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
2019-01-04 20:35:28 +01:00
|
|
|
//! Generates symmetric (vertically mirrored) identicons.
|
2019-01-03 13:27:49 +01:00
|
|
|
identiconpp_ltr_symmetric,
|
2019-01-04 20:35:28 +01:00
|
|
|
//! Generates asymmetric identicons.
|
2019-01-03 13:27:49 +01:00
|
|
|
identiconpp_ltr_asymmetric,
|
2019-01-04 20:35:28 +01:00
|
|
|
/*!
|
|
|
|
* Generates the same results as
|
|
|
|
* [sigil](https://github.com/cupcake/sigil/) and
|
|
|
|
* [pydenticon](https://github.com/azaghal/pydenticon/).
|
|
|
|
*/
|
2019-01-03 13:27:49 +01:00
|
|
|
identiconpp_sigil
|
|
|
|
} identiconpp_algorithm;
|
|
|
|
|
2019-01-04 17:36:10 +01:00
|
|
|
/*!
|
|
|
|
* @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 }
|
|
|
|
*
|
2019-01-04 20:35:28 +01:00
|
|
|
* @return false on error, true otherwise.
|
2019-01-04 17:36:10 +01:00
|
|
|
*/
|
2019-01-03 13:27:49 +01:00
|
|
|
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]);
|
2019-01-04 17:36:10 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @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
|
|
|
|
*
|
2019-01-04 19:10:01 +01:00
|
|
|
* @return Length of the generated base64-string, or 0 on error.
|
2019-01-04 17:36:10 +01:00
|
|
|
*/
|
|
|
|
uint64_t identiconpp_generate(const char magick[],
|
|
|
|
const char digest[], const uint16_t width);
|
2019-01-04 19:13:38 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Return base64-encoded string of the image generated with
|
|
|
|
* identiconpp_generate().
|
|
|
|
*/
|
2019-01-04 17:36:10 +01:00
|
|
|
const char *identiconpp_base64();
|
2019-01-03 13:27:49 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2019-01-07 13:54:37 +01:00
|
|
|
#endif // IDENTICONPP_C_H
|