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 <cstdint>
7#include <span>
8#include <string>
9
10namespace openmsx {
11
12class SDLImage final : public BaseImage
13{
14public:
15 SDLImage(OutputSurface& output, const std::string& filename);
17 SDLImage(OutputSurface& output, const std::string& filename, float scaleFactor);
18 SDLImage(OutputSurface& output, const std::string& filename, gl::ivec2 size);
19 SDLImage(OutputSurface& output, gl::ivec2 size, uint32_t rgba);
20 SDLImage(OutputSurface& output, gl::ivec2 size, std::span<const uint32_t, 4> rgba,
21 int borderSize, uint32_t borderRGBA);
22
23 void draw(OutputSurface& output, gl::ivec2 pos,
24 uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override;
25
26private:
27 [[nodiscard]] SDLTexturePtr toTexture(OutputSurface& output, SDL_Surface& surface);
28 [[nodiscard]] SDLTexturePtr loadImage(OutputSurface& output, const std::string& filename);
29 void initSolid(OutputSurface& output, gl::ivec2 size, uint32_t rgba,
30 int borderSize, uint32_t borderRGBA);
31 void initGradient(OutputSurface& output, gl::ivec2 size, std::span<const uint32_t, 4> rgba,
32 int borderSize, uint32_t borderRGBA);
33
34private:
35 SDLTexturePtr texture; // can be nullptr
36 const bool flipX, flipY; // 'size' is always positive, there are true
37 // when the original size was negative
38};
39
40} // namespace openmsx
41
42#endif
std::string image
Definition: HDImageCLI.cc:13
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
This file implemented 3 utility functions:
Definition: Autofire.cc:9