SDLImage.hh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef SDLIMAGE_HH
  2. #define SDLIMAGE_HH
  3. #include "BaseImage.hh"
  4. #include "SDLSurfacePtr.hh"
  5. #include <string>
  6. namespace openmsx {
  7. class SDLImage final : public BaseImage
  8. {
  9. public:
  10. SDLImage(OutputSurface& output, const std::string& filename);
  11. SDLImage(OutputSurface& output, SDLSurfacePtr image);
  12. SDLImage(OutputSurface& output, const std::string& filename, float scaleFactor);
  13. SDLImage(OutputSurface& output, const std::string& filename, gl::ivec2 size);
  14. SDLImage(OutputSurface& output, gl::ivec2 size, unsigned rgba);
  15. SDLImage(OutputSurface& output, gl::ivec2 size, const unsigned* rgba,
  16. unsigned borderSize, unsigned borderRGBA);
  17. void draw(OutputSurface& output, gl::ivec2 pos,
  18. uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override;
  19. private:
  20. SDLTexturePtr toTexture(OutputSurface& output, SDL_Surface& surface);
  21. SDLTexturePtr loadImage(OutputSurface& output, const std::string& filename);
  22. void initSolid(OutputSurface& output, gl::ivec2 size, unsigned rgba,
  23. unsigned borderSize, unsigned borderRGBA);
  24. void initGradient(OutputSurface& output, gl::ivec2 size, const unsigned* rgba,
  25. unsigned borderSize, unsigned borderRGBA);
  26. SDLTexturePtr texture; // can be nullptr
  27. const bool flipX, flipY; // 'size' is always positive, there are true
  28. // when the original size was negative
  29. };
  30. } // namespace openmsx
  31. #endif