ImageExport.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. /**
  46. * \brief generates and saves a fractal image in png format.
  47. *
  48. * \param iei info to generate the image
  49. * \param progressCallback optional function that is called to
  50. * report progress; the float parameter
  51. * contains a value from 0 to 100
  52. */
  53. void exportPng(const ImageExportInfo& iei,
  54. std::function<void(float)> progressCallback = [](float){});
  55. #ifdef WITH_LIBJPEG
  56. /**
  57. * \brief generates and saves a fractal image in jpeg format.
  58. *
  59. * \param iei info to generate the image
  60. * \param progressCallback optional function that is called to
  61. * report progress; the float parameter
  62. * contains a value from 0 to 100
  63. */
  64. void exportJpeg(const ImageExportInfo& iei,
  65. std::function<void(float)> progressCallback = [](float){});
  66. #endif // WITH_LIBJPEG
  67. /**
  68. * \brief generates and saves a fractal image in jpeg format.
  69. *
  70. * \param iei info to generate the image
  71. * \param progressCallback optional function that is called to
  72. * report progress; the float parameter
  73. * contains a value from 0 to 100
  74. */
  75. void exportBmp(const ImageExportInfo& iei,
  76. std::function<void(float)> progressCallback = [](float){});
  77. }
  78. #endif // LIBALMOND_IMAGEEXPORT_H