example7.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. #include <libcaptcha.h>
  3. /*
  4. * Generate screenshot using a new preset functions.
  5. */
  6. int main() {
  7. lc_bmp * text = lc_preset_text("../ttf/dejavu.ttf", "HELLOWORLD", 38, 50, 0, 10, 10);
  8. lc_bmp * bmp = lc_create_3ch_bmp(text->w * 3 + 3, text->h * 2 + 2); //6 images
  9. int ow = text->w;
  10. int oh = text->h;
  11. lc_bmp * square = lc_preset_square(text, 1, 2);
  12. lc_merge_3ch_bmp(bmp, square, 0, 0);
  13. lc_free(square);
  14. square = lc_preset_square(text, 2, 15);
  15. lc_merge_3ch_bmp(bmp, square, text->w + 1, 0);
  16. lc_free(square);
  17. square = lc_preset_square(text, 2, 20);
  18. lc_merge_3ch_bmp(bmp, square, text->w * 2 + 1, 0);
  19. lc_free(square);
  20. lc_bmp * noise = lc_preset_noise(text);
  21. lc_merge_3ch_bmp(bmp, noise, 0, text->h + 1);
  22. lc_free(noise);
  23. square = lc_preset_circle(text, 0, 14);
  24. lc_merge_3ch_bmp(bmp, square, ow + 1, oh + 1);
  25. lc_free(square);
  26. square = lc_preset_circle(text, 0, 30);
  27. lc_merge_3ch_bmp(bmp, square, ow * 2 + 1, oh+ 1);
  28. lc_free(square);
  29. lc_save_png("example7.png", bmp);
  30. lc_free(bmp);
  31. lc_free(text);
  32. return 0;
  33. }