identiconpp is a library to generate identicons for C++ and C.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ltr_asymmetric.cpp 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This file is part of identiconpp.
  2. * Copyright © 2018 tastytea <tastytea@tastytea.de>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 3.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "identiconpp.hpp"
  17. #include "debug.hpp"
  18. Magick::Image Identiconpp::generate_ltr_asymmetric(const string &digest)
  19. {
  20. Magick::Image img(Magick::Geometry(_columns, _rows),
  21. Magick::Color('#' + _background));
  22. Magick::Color dotcolor = get_color(_columns * _rows + 1, digest);
  23. for (uint8_t row = 0; row < _rows; ++row)
  24. {
  25. for (uint8_t column = 0; column < _columns; ++column)
  26. {
  27. if (get_bit(row * _columns + column, digest))
  28. {
  29. ttdebug << "col=" << std::to_string(column)
  30. << ", row=" << std::to_string(row) << '\n';
  31. img.pixelColor(column, row, dotcolor);
  32. }
  33. }
  34. }
  35. return img;
  36. }