openMSX
SDLImage.hh
Go to the documentation of this file.
1 #ifndef SDLIMAGE_HH
2 #define SDLIMAGE_HH
3 
4 #include "BaseImage.hh"
5 #include "SDLSurfacePtr.hh"
6 #include "span.hh"
7 #include <string>
8 
9 namespace openmsx {
10 
11 class SDLImage final : public BaseImage
12 {
13 public:
14  SDLImage(OutputSurface& output, const std::string& filename);
16  SDLImage(OutputSurface& output, const std::string& filename, float scaleFactor);
17  SDLImage(OutputSurface& output, const std::string& filename, gl::ivec2 size);
18  SDLImage(OutputSurface& output, gl::ivec2 size, unsigned rgba);
20  unsigned borderSize, unsigned borderRGBA);
21 
22  void draw(OutputSurface& output, gl::ivec2 pos,
23  uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override;
24 
25 private:
26  [[nodiscard]] SDLTexturePtr toTexture(OutputSurface& output, SDL_Surface& surface);
27  [[nodiscard]] SDLTexturePtr loadImage(OutputSurface& output, const std::string& filename);
28  void initSolid(OutputSurface& output, gl::ivec2 size, unsigned rgba,
29  unsigned borderSize, unsigned borderRGBA);
30  void initGradient(OutputSurface& output, gl::ivec2 size, span<const unsigned, 4> rgba,
31  unsigned borderSize, unsigned borderRGBA);
32 
33 private:
34  SDLTexturePtr texture; // can be nullptr
35  const bool flipX, flipY; // 'size' is always positive, there are true
36  // when the original size was negative
37 };
38 
39 } // namespace openmsx
40 
41 #endif
string image
Definition: HDImageCLI.cc:15
std::unique_ptr< SDL_Texture, SDLDestroyTexture > SDLTexturePtr
int g
Wrapper around a SDL_Surface.
gl::ivec2 size
Definition: BaseImage.hh:31
A frame buffer where pixels can be written to.
SDLImage(OutputSurface &output, const std::string &filename)
Definition: SDLImage.cc:206
void draw(OutputSurface &output, gl::ivec2 pos, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override
Definition: SDLImage.cc:369
Definition: span.hh:126
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr const char *const filename