2018-12-25 21:39:23 +01:00
<!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 >
2019-07-30 14:02:33 +02:00
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/searchdata.js" > < / script >
< script type = "text/javascript" src = "search/search.js" > < / script >
2018-12-25 21:39:23 +01:00
< 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
2019-07-30 14:02:33 +02:00
  < span id = "projectnumber" > 0.6.1< / span >
2018-12-25 21:39:23 +01:00
< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
2019-07-30 14:02:33 +02:00
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
< / script >
2018-12-25 21:39:23 +01:00
< 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() {
2019-07-30 14:02:33 +02:00
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
2018-12-25 21:39:23 +01:00
});
/* @license-end */< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
2019-07-30 14:02:33 +02:00
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< iframe src = "javascript:void(0)" frameborder = "0"
name="MSearchResults" id="MSearchResults">
< / iframe >
< / div >
2018-12-25 21:39:23 +01:00
< div class = "header" >
< div class = "headertitle" >
< div class = "title" > identiconpp Documentation< / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
2019-01-04 19:39:00 +01:00
< div class = "textblock" > < p > < b > identiconpp< / b > is a library to generate identicons for C++ and C.< / p >
2018-12-26 19:25:03 +01:00
< p > You get the images as < code > Magick::Image< / code > . This allows you to make all kinds of modifications.< / p >
2018-12-28 02:03:27 +01:00
< 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 >
2019-01-04 19:39:00 +01:00
< p > The example images above are generated using < a href = "https://schlomp.space/tastytea/identiconpp/src/branch/master/example.cpp" > example.cpp< / a > .< / p >
2018-12-25 21:39:23 +01:00
< h2 > Features< / h2 >
2018-12-26 19:25:03 +01:00
< ul >
2018-12-26 23:58:01 +01:00
< li > [x] Symmetric identicons< / li >
< li > [x] sigil identicons< / li >
2018-12-27 06:33:24 +01:00
< li > [x] Asymmetric identicons< / li >
< li > [x] Padding< / li >
2018-12-26 19:25:03 +01:00
< / ul >
2018-12-26 04:40:04 +01:00
< h2 > Usage< / h2 >
2019-07-30 14:02:33 +02:00
< p > The HTML reference can be generated with < code > build_doc.sh< / code > , if doxygen is installed. It is also available at < a href = "https://doc.schlomp.space/identiconpp/classIdenticonpp.html" > doc.schlomp.space/identiconpp/< / a > .< / p >
2018-12-26 23:58:01 +01:00
< 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 >
2018-12-28 02:03:27 +01:00
< 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 >
2018-12-26 19:25:03 +01:00
< h3 > Example< / h3 >
2019-07-30 14:02:33 +02:00
< div class = "fragment" > < div class = "line" > // Compile with g++ $(pkg-config --libs --cflags identiconpp)< / 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 >
2019-01-07 13:57:41 +01:00
< 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 >
2019-01-04 19:39:00 +01:00
< 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 >
2018-12-26 19:25:03 +01:00
< 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 >
2019-07-30 14:02:33 +02:00
< p > Binary packages are generated automatically for each < a href = "https://schlomp.space/tastytea/identiconpp/releases" > release< / a > in the formats < code > deb< / code > and < code > rpm< / code > . They are signed with my < a href = "https://tastytea.de/tastytea_autosign.asc" > automatic signing key< / a > .< / p >
2018-12-25 21:39:23 +01:00
< h3 > From source< / h3 >
< h4 > Dependencies< / h4 >
< ul >
2019-07-30 14:02:33 +02:00
< li > C++ compiler (tested: < a href = "https://gcc.gnu.org/" > gcc< / a > 6/8/9, < a href = "https://llvm.org/" > clang< / a > 6)< / li >
2018-12-25 21:39:23 +01:00
< 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 >
2019-01-02 06:44:59 +01:00
< li > Optional:< ul >
< li > Tests: < a href = "https://github.com/catchorg/Catch2" > Catch< / a > (tested: 2.3 / 1.2)< / li >
< / ul >
< / li >
2018-12-25 21:39:23 +01:00
< / ul >
2018-12-26 19:25:03 +01:00
< p > On a Debian system, install the packages: < code > build-essential cmake libmagick++-dev< / code > .< / p >
2018-12-25 21:39:23 +01:00
< 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 >
2019-01-04 19:39:00 +01:00
< li > < code > -DWITH_TESTS=YES< / code > to build tests< / li >
2018-12-26 19:25:03 +01:00
< 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 >
2018-12-25 21:39:23 +01:00
< / ul >
2018-12-26 19:25:03 +01:00
< p > To generate a binary package, execute < code > make package< / code > < / p >
2018-12-25 21:39:23 +01:00
< h2 > Contributing< / h2 >
2019-01-07 13:57:41 +01:00
< 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 >
2018-12-25 21:39:23 +01:00
< h2 > Contact< / h2 >
< p > See < a href = "https://tastytea.de/" > https://tastytea.de/< / a > < / p >
< h2 > License & Copyright< / h2 >
2018-12-26 23:58:01 +01:00
< 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 >
2018-12-28 02:03:27 +01:00
< 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 >
2018-12-26 23:58:01 +01:00
< 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 >
2018-12-27 06:33:24 +01:00
< 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 >
2018-12-28 02:03:27 +01:00
< li > Use the following bits to pick the foreground color.< ul >
2019-07-30 14:02:33 +02:00
< li > You need < code > floor(log2(n_colors)) + 1< / code > bits.< / li >
2018-12-28 02:03:27 +01:00
< / ul >
< / li >
2018-12-27 06:33:24 +01:00
< 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 >
2018-12-26 23:58:01 +01:00
< 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 -->
2018-12-25 21:39:23 +01:00
<!-- 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 >