ImageDecoder.h 786 B

1234567891011121314151617181920
  1. #pragma once
  2. #include <cstddef>
  3. #include <stb_image.h>
  4. namespace WallpaperEngine::Render {
  5. /**
  6. * Decodes an encoded image (jpeg, png...) to RGBA8 the way WE's resourceutil64 does it: FreeImage with
  7. * JPEG_EXIFROTATE, so jpegs come out in their EXIF orientation. Free the result with stbi_image_free.
  8. */
  9. stbi_uc* decodeImageRGBA (const void* data, size_t size, int& width, int& height);
  10. // decoded size without decoding
  11. bool decodedImageSize (const void* data, size_t size, int& width, int& height);
  12. /** GL_MAX_TEXTURE_SIZE, checked before decoding so a bogus header can't allocate gigabytes. 0 = no limit */
  13. void setMaxImageSide (int side);
  14. [[nodiscard]] int maxImageSide ();
  15. [[nodiscard]] bool exceedsMaxImageSide (int width, int height);
  16. } // namespace WallpaperEngine::Render