preset0_test.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. * Author: g0tsu
  12. * Email: g0tsu at dnmx.0rg
  13. */
  14. #include <stdio.h>
  15. #include <assert.h>
  16. #include <libcaptcha.h>
  17. #include <errno.h>
  18. #include <global.h>
  19. #define STB_IMAGE_WRITE_IMPLEMENTATION
  20. #include "stb_image_write.h"
  21. static int create_obj() {
  22. lc_bmp *bmp = lc_preset_text("../ttf/dejavu.ttf", "HELLOWORLD", 38, 60, 1, 20, 20);
  23. if (!bmp) {
  24. perror("lc_reset_text()");
  25. return 1;
  26. }
  27. /* lc_save_png("/tmp/out.png", bmp);*/
  28. lc_free(bmp);
  29. return 0;
  30. }
  31. static int create_obj_noise() {
  32. lc_bmp *bmp = lc_preset_text("../ttf/dejavu.ttf", "HELLOWORLD", 38, 60, 0, 10, 10);
  33. lc_bmp *noise;
  34. if (!bmp) {
  35. perror("lc_reset_text()");
  36. return 1;
  37. }
  38. noise = lc_preset_noise(bmp);
  39. if (!noise) {
  40. lc_free(bmp);
  41. return 1;
  42. }
  43. /* lc_save_png("/tmp/out.png", noise);*/
  44. lc_free(bmp);
  45. lc_free(noise);
  46. return 0;
  47. }
  48. int main() {
  49. assert(!create_obj());
  50. assert(!create_obj_noise());
  51. return 0;
  52. }