3
0

ImagePreview.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Processing/ImageConvertJob.h>
  10. #include <AzCore/Jobs/JobCompletion.h>
  11. class QImage;
  12. namespace ImageProcessingAtom
  13. {
  14. // The reason to have image preview class, we should keep the source image loaded once,
  15. // we could restart conversion and cancel the old conversion at anytime when setting changed
  16. class ImagePreview
  17. {
  18. public:
  19. ImagePreview(const AZStd::string& inputImageFile, TextureSettings* textureSetting);
  20. ~ImagePreview();
  21. void InitializeJobSettings();
  22. void StartConvert();
  23. bool IsDone();
  24. float GetProgress();
  25. void Cancel();
  26. IImageObjectPtr GetOutputImage();
  27. private:
  28. AZStd::string m_imageFileName;
  29. IImageObjectPtr m_inputImage;
  30. const TextureSettings* m_textureSetting;
  31. const PresetSettings* m_presetSetting;
  32. IImageObjectPtr m_outputImage;
  33. IImageObjectPtr m_outputAlphaImage;
  34. ImageConvertOutput m_output;
  35. AZStd::unique_ptr<AZ::JobManager> m_jobManager;
  36. AZStd::unique_ptr<AZ::JobCancelGroup> m_jobCancelGroup;
  37. AZStd::unique_ptr<AZ::JobContext> m_jobContext;
  38. AZStd::unique_ptr<ImagePreviewConvertJob> m_convertJob;
  39. AZ::JobCompletion m_doneJob;
  40. };
  41. }// namespace ImageProcessingAtom