identiconpp/example.cpp

69 lines
1.7 KiB
C++
Raw Permalink Normal View History

2018-12-25 18:33:19 +01:00
/* This file is part of identiconpp.
* Public Domain / CC-0
*
* Compile with g++ $(Magick++-config --cppflags --ldflags) -lidenticonpp
2018-12-25 18:33:19 +01:00
*/
#include <string>
#include <Magick++/Image.h>
#include "identiconpp.hpp"
2018-12-25 18:33:19 +01:00
int main(int argc, char *argv[])
{
string digest =
"973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b";
Magick::Image img;
2018-12-25 18:33:19 +01:00
if (argc > 1)
{
digest = argv[1];
2018-12-25 18:33:19 +01:00
}
{
Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_symmetric,
2018-12-27 05:21:40 +01:00
"ffffff80",
2018-12-26 04:36:58 +01:00
{
"000000ff",
"ff0000ff",
"ffff00ff",
"00ff00ff",
"00ffffff",
"0000ffff"
2018-12-27 06:13:49 +01:00
}, { 10, 10 });
img = identicon.generate(digest, 500);
img.write("identicon_example_ltr_symmetric.png");
2018-12-26 04:36:58 +01:00
}
2018-12-27 05:21:40 +01:00
{
Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_asymmetric,
"00000080",
{
"ffffffc0",
"ff0000c0",
"ffff00c0",
"00ff00c0",
"00ffffc0",
"0000ffc0"
});
img = identicon.generate(digest, 500);
img.write("identicon_example_ltr_asymmetric.png");
}
2018-12-26 22:16:11 +01:00
{
Identiconpp identicon(5, 5, Identiconpp::algorithm::sigil,
2018-12-26 22:16:11 +01:00
"ffffffff",
{
"000000ff",
"ff0000ff",
"ffff00ff",
"00ff00ff",
"00ffffff",
"0000ffff"
});
img = identicon.generate(digest, 500);
img.write("identicon_example_sigil.png");
2018-12-26 22:16:11 +01:00
}
2018-12-25 18:33:19 +01:00
return 0;
}