1
0

ImageExport.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef LIBALMOND_IMAGEEXPORT_H
  2. #define LIBALMOND_IMAGEEXPORT_H
  3. #include "Mandel.h"
  4. #include "Gradient.h"
  5. #include <functional>
  6. #include <vector>
  7. #include <stdexcept>
  8. namespace alm
  9. {
  10. enum class ImageFormat
  11. {
  12. BMP,
  13. PNG,
  14. JPEG
  15. };
  16. bool supportsImageFormat(ImageFormat imgf);
  17. struct ImageOptions
  18. {
  19. int jpegQuality = 80;
  20. };
  21. struct ImageExportInfo
  22. {
  23. mnd::MandelInfo drawInfo;
  24. mnd::MandelGenerator* generator;
  25. Gradient gradient;
  26. ImageOptions options;
  27. std::string path;
  28. };
  29. struct ImageExportException :
  30. std::runtime_error
  31. {
  32. ImageExportException(const std::string& err);
  33. };
  34. /**
  35. * \brief generates and saves a fractal image. The format
  36. * will be guessed by the file extension
  37. *
  38. * \param iei info to generate the image
  39. * \param progressCallback optional function that is called to
  40. * report progress; the float parameter
  41. * contains a value from 0 to 100
  42. */
  43. void exportImage(const ImageExportInfo& iei,
  44. std::function<void(float)> progressCallback = [](float){},
  45. std::function<bool(void)> cancelCallback = [](void){ return false; }
  46. );
  47. }
  48. #endif // LIBALMOND_IMAGEEXPORT_H