172 lines
10 KiB
HTML
172 lines
10 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>identiconpp: Main Page</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">identiconpp
|
|
 <span id="projectnumber">0.6.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',false,false,'search.php','Search');
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">identiconpp Documentation</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p><b>identiconpp</b> is a library to generate identicons for C++ and C.</p>
|
|
<p>You get the images as <code>Magick::Image</code>. This allows you to make all kinds of modifications.</p>
|
|
<div class="image">
|
|
<img src="https://doc.schlomp.space/identiconpp/identicon1.png" title="4x4 identicon, ltr_symmetric, 20px padding"/>
|
|
</div>
|
|
<div class="image">
|
|
<img src="https://doc.schlomp.space/identiconpp/identicon2.png" title="5x5 identicon, sigil"/>
|
|
</div>
|
|
<div class="image">
|
|
<img src="https://doc.schlomp.space/identiconpp/identicon3.png" title="5x5 identicon, ltr_asymmetric"/>
|
|
</div>
|
|
<div class="image">
|
|
<img src="https://doc.schlomp.space/identiconpp/identicon4.png" title="6x4 identicon, ltr_symmetric, 10px padding"/>
|
|
</div>
|
|
<p>The example images above are generated using <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/example.cpp">example.cpp</a>.</p>
|
|
<h2>Features</h2>
|
|
<ul>
|
|
<li>[x] Symmetric identicons</li>
|
|
<li>[x] sigil identicons</li>
|
|
<li>[x] Asymmetric identicons</li>
|
|
<li>[x] Padding</li>
|
|
</ul>
|
|
<h2>Usage</h2>
|
|
<p>The HTML reference can be generated with build_doc.sh, if doxygen is installed. It is also available at <a href="https://doc.schlomp.space/identiconpp/classIdenticonpp.html">doc.schlomp.space/identiconpp/</a>.</p>
|
|
<p>You need to generate hashes yourself, any hexadecimal string will do. Make sure to use a safe hashing algorithm for sensitive data (<b>not MD5</b>). You can select as many columns and rows as you like, but make sure you have enough entropy. If something seems to be wrong, exceptions will be thrown.</p>
|
|
<p>The "sigil" algorithm generates the same results as <a href="https://github.com/cupcake/sigil/">sigil</a> and <a href="https://github.com/azaghal/pydenticon/">pydenticon</a>.</p>
|
|
<h3>Example</h3>
|
|
<div class="fragment"><div class="line">{C++}</div><div class="line">// Compile with g++ $(Magick++-config --cppflags --ldflags) -lidenticonpp</div><div class="line">#include <iostream></div><div class="line">#include <identiconpp.hpp></div><div class="line">#include <Magick++/Image.h></div><div class="line"></div><div class="line">int main()</div><div class="line">{</div><div class="line"> Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_symmetric,</div><div class="line"> "ffffff80", { "800000ff" }, { 10, 10 });</div><div class="line"> Magick::Image img;</div><div class="line"> img = identicon.generate("55502f40dc8b7c769880b10874abc9d0", 200);</div><div class="line"> img.write("identicon.png");</div><div class="line"></div><div class="line"> std::cout << identicon.generate_base64("png", "5550", 200) << std::endl;</div><div class="line">}</div></div><!-- fragment --><h3>C interface</h3>
|
|
<p>This is somewhat experimental. Have a look at <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/example.c">example.c</a> and <a href="https://doc.schlomp.space/identiconpp/identiconpp__c_8h.html">identiconpp_c.h</a>.</p>
|
|
<p>It seems to be impossible to use <code>Magick++</code> and <code>MagickWand</code> in the same library, so the images are returned as base64-encoded strings.</p>
|
|
<h2>Install</h2>
|
|
<h3>Gentoo</h3>
|
|
<p>Gentoo ebuilds are available via my <a href="https://schlomp.space/tastytea/overlay">repository</a>.</p>
|
|
<h3>Automatically generated packages</h3>
|
|
<p>Binary packages are generated automatically for each <a href="https://schlomp.space/tastytea/identiconpp/releases">release</a> in the formats:</p>
|
|
<ul>
|
|
<li>deb</li>
|
|
<li>rpm</li>
|
|
<li>tar.gz</li>
|
|
</ul>
|
|
<p>They are generated on Debian Stretch 64 bit and signed with my <a href="https://tastytea.de/tastytea_autosign.asc">automatic signing key</a>.</p>
|
|
<h3>From source</h3>
|
|
<h4>Dependencies</h4>
|
|
<ul>
|
|
<li>C++ compiler (tested: <a href="https://gcc.gnu.org/">gcc</a> 5/6/7/8, <a href="https://llvm.org/">clang</a> 5/6)</li>
|
|
<li><a href="https://cmake.org/">cmake</a> (at least 3.2)</li>
|
|
<li><a href="https://www.imagemagick.org/">imagemagick</a> (tested: 7.0 / 6.7)</li>
|
|
<li>Optional:<ul>
|
|
<li>Tests: <a href="https://github.com/catchorg/Catch2">Catch</a> (tested: 2.3 / 1.2)</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<p>On a Debian system, install the packages: <code>build-essential cmake libmagick++-dev</code>.</p>
|
|
<h4>Compile</h4>
|
|
<div class="fragment"><div class="line">mkdir build</div><div class="line">cd build</div><div class="line">cmake ..</div><div class="line">make</div><div class="line">make install</div></div><!-- fragment --><h5>cmake options</h5>
|
|
<ul>
|
|
<li><code>-DCMAKE_BUILD_TYPE=Debug</code> for a debug build</li>
|
|
<li><code>-DWITH_TESTS=YES</code> to build tests</li>
|
|
<li>One of:<ul>
|
|
<li><code>-DWITH_DEB=YES</code> to generate a deb-package</li>
|
|
<li><code>-DWITH_RPM=YES</code> to generate an rpm-package</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<p>To generate a binary package, execute <code>make package</code></p>
|
|
<h2>Contributing</h2>
|
|
<p>Contributions are always welcome. You can submit them as pull requests on schlomp.space or via email to <code>tastytea</code><tt>tastytea.de (ideally using <code>git format-patch</code> or <code>git send-email</code>). Please do not submit them via GitHub, it is just a mirror.</p>
|
|
<h2>Contact</h2>
|
|
<p>See <a href="https://tastytea.de/">https://tastytea.de/</a></p>
|
|
<h2>License & Copyright</h2>
|
|
<div class="fragment"><div class="line">Copyright © 2018 tastytea <tastytea@tastytea.de>.</div><div class="line">License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.</div><div class="line">This program comes with ABSOLUTELY NO WARRANTY. This is free software,</div><div class="line">and you are welcome to redistribute it under certain conditions.</div></div><!-- fragment --><h2>Algorithms</h2>
|
|
<h3>ltr_symmetric</h3>
|
|
<ul>
|
|
<li>Create image with width=columns, height=rows.</li>
|
|
<li>Set background color.</li>
|
|
<li>Select half of the columns, or half of the columns + 1 if uneven.<ul>
|
|
<li><code>columns / 2 + columns % 2</code></li>
|
|
</ul>
|
|
</li>
|
|
<li>Pixels are drawn from left to right, top to bottom.</li>
|
|
<li>Use bits from digest to determine if a pixel is painted(1) or not(0).</li>
|
|
<li>Mirror the pixels vertically.</li>
|
|
<li>Use the following bits to pick the foreground color.<ul>
|
|
<li>You need <code>floor(log2(n_colors)) + 1</code> bits.</li>
|
|
</ul>
|
|
</li>
|
|
<li>Scale image proportionally to requested width.</li>
|
|
</ul>
|
|
<div class="fragment"><div class="line"> 0111 0011 1101 1100 […] 1111 0111 0101 0111</div><div class="line">^ ^</div><div class="line">+----------------------------+--------------></div><div class="line"> | |</div><div class="line"> pixel matrix foreground color</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_symmetric.cpp">ltr_symmetric.cpp</a></p>
|
|
<h3>ltr_asymmetric</h3>
|
|
<ul>
|
|
<li>Create image with width=columns, height=rows.</li>
|
|
<li>Set background color.</li>
|
|
<li>Pixels are drawn from left to right, top to bottom.</li>
|
|
<li>Use bits from digest to determine if a pixel is painted(1) or not(0).</li>
|
|
<li>Use the following bits to pick the foreground color.<ul>
|
|
<li>* You need <code>floor(log2(n_colors)) + 1</code> bits.</li>
|
|
</ul>
|
|
</li>
|
|
<li>Scale image proportionally to requested width.</li>
|
|
</ul>
|
|
<div class="fragment"><div class="line"> 0111 0011 1101 1100 […] 1111 0111 0101 0111</div><div class="line">^ ^</div><div class="line">+----------------------------+--------------></div><div class="line"> | |</div><div class="line"> pixel matrix foreground color</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/ltr_asymmetric.cpp">ltr_asymmetric.cpp</a></p>
|
|
<h3>sigil</h3>
|
|
<ul>
|
|
<li>Create image with width=columns, height=rows.</li>
|
|
<li>Set background color.</li>
|
|
<li>Select half of the columns, or half of the columns + 1 if uneven.<ul>
|
|
<li><code>columns / 2 + columns % 2</code></li>
|
|
</ul>
|
|
</li>
|
|
<li>Pixels are drawn from top to bottom, left to right.</li>
|
|
<li>Use the first 8 bits to pick the foreground color.</li>
|
|
<li>Use the following bits to determine if a pixel is painted(1) or not(0).</li>
|
|
<li>Mirror the pixels vertically.</li>
|
|
<li>Scale image proportionally to requested width.</li>
|
|
</ul>
|
|
<div class="fragment"><div class="line"> 0111 0011 1101 1100</div><div class="line">^ ^</div><div class="line">+---------+---------></div><div class="line"> | |</div><div class="line">foreground color |</div><div class="line"> pixel matrix</div></div><!-- fragment --><p>Implemented in <a href="https://schlomp.space/tastytea/identiconpp/src/branch/master/src/sigil.cpp">sigil.cpp</a> </p>
|
|
</div></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.14
|
|
</small></address>
|
|
</body>
|
|
</html>
|