IImageUtil.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef CRYINCLUDE_EDITOR_INCLUDE_IIMAGEUTIL_H
  9. #define CRYINCLUDE_EDITOR_INCLUDE_IIMAGEUTIL_H
  10. #pragma once
  11. #include "Util/Image.h"
  12. class CAlphaBitmap;
  13. struct IImageUtil
  14. {
  15. virtual ~IImageUtil() = default;
  16. //! Load image, detect image type by file extension.
  17. // Arguments:
  18. // pQualityLoss - 0 if info is not needed, pointer to the result otherwise - not need to preinitialize
  19. virtual bool LoadImage(const QString& fileName, CImageEx& image, bool* pQualityLoss = 0) = 0;
  20. //! Save image, detect image type by file extension.
  21. virtual bool SaveImage(const QString& fileName, CImageEx& image) = 0;
  22. // General image fucntions
  23. virtual bool LoadJPEG(const QString& strFileName, CImageEx& image) = 0;
  24. virtual bool SaveJPEG(const QString& strFileName, CImageEx& image) = 0;
  25. virtual bool SaveBitmap(const QString& szFileName, CImageEx& image) = 0;
  26. virtual bool LoadBmp(const QString& file, CImageEx& image) = 0;
  27. virtual bool SavePGM(const QString& fileName, const CImageEx& image) = 0;
  28. virtual bool LoadPGM(const QString& fileName, CImageEx& image) = 0;
  29. //! Scale source image to fit size of target image.
  30. virtual void ScaleToFit(const CByteImage& srcImage, CByteImage& trgImage) = 0;
  31. //! Scale source image to fit size of target image.
  32. virtual void ScaleToFit(const CImageEx& srcImage, CImageEx& trgImage) = 0;
  33. //! Scale source image to fit twice side by side in target image.
  34. virtual void ScaleToDoubleFit(const CImageEx& srcImage, CImageEx& trgImage) = 0;
  35. //! Scale source image twice down image with filering
  36. enum _EAddrMode
  37. {
  38. WRAP, CLAMP
  39. };
  40. virtual void DownScaleSquareTextureTwice(const CImageEx& srcImage, CImageEx& trgImage, _EAddrMode eAddressingMode = WRAP) = 0;
  41. //! Smooth image.
  42. virtual void SmoothImage(CByteImage& image, int numSteps) = 0;
  43. //! behavior outside of the texture is not defined
  44. //! \param iniX in fix point 24.8
  45. //! \param iniY in fix point 24.8
  46. //! \return 0..255
  47. virtual unsigned char GetBilinearFilteredAt(const int iniX256, const int iniY256, const CByteImage& image) = 0;
  48. };
  49. #endif // CRYINCLUDE_EDITOR_INCLUDE_IIMAGEUTIL_H