Etterna 0.74.4
Loading...
Searching...
No Matches
RageSurface.h
1/* RageSurface - holds a simple 2d graphic surface */
2
3#ifndef RAGE_SURFACE_H
4#define RAGE_SURFACE_H
5
6/* XXX remove? */
8{
9 uint8_t r, g, b, a;
11 : r(0)
12 , g(0)
13 , b(0)
14 , a(0)
15 {
16 }
17 RageSurfaceColor(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_)
18 : r(r_)
19 , g(g_)
20 , b(b_)
21 , a(a_)
22 {
23 }
24};
25
26inline auto
27operator==(RageSurfaceColor const& lhs, RageSurfaceColor const& rhs) -> bool
28{
29 return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && lhs.a == rhs.a;
30}
31
32inline auto
33operator!=(RageSurfaceColor const& lhs, RageSurfaceColor const& rhs) -> bool
34{
35 return !operator==(lhs, rhs);
36}
37
39{
40 RageSurfaceColor colors[256];
41 int32_t ncolors{};
42
43 /* Find the exact color; returns -1 if not found. */
44 [[nodiscard]] auto FindColor(const RageSurfaceColor& color) const
45 -> int32_t;
46 [[nodiscard]] auto FindClosestColor(const RageSurfaceColor& color) const
47 -> int32_t;
48};
49
51{
55
56 int32_t BytesPerPixel = 1;
57 int32_t BitsPerPixel = 8;
58 uint32_t Mask[4];
59 uint32_t Shift[4];
60 uint8_t Loss[4];
61 uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */
62 uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */
63 RageSurfacePalette* palette;
64
65 void GetRGB(uint32_t val, uint8_t* r, uint8_t* g, uint8_t* b) const;
66
67 /* Return the decoded value for the given color; the result can be compared
68 * to decodepixel() results. If the image is paletted and the color isn't
69 * found, val is undefined and false is returned. */
70 auto MapRGBA(uint8_t r,
71 uint8_t g,
72 uint8_t b,
73 uint8_t a,
74 uint32_t& val) const -> bool;
75
76 /* MapRGBA, but also do a nearest-match on palette colors. */
77 [[nodiscard]] auto MapNearestRGBA(uint8_t r,
78 uint8_t g,
79 uint8_t b,
80 uint8_t a) const -> uint32_t;
81
82 auto operator==(const RageSurfaceFormat& rhs) const -> bool;
83
84 /* Like operator==, but ignores the palette (which is really a part of the
85 * surface, not the format). */
86 [[nodiscard]] auto Equivalent(const RageSurfaceFormat& rhs) const -> bool;
87};
88
90{
92 uint8_t* pixels;
93 bool pixels_owned;
94 bool stb_loadpoint;
95 int32_t w = 0, h = 0, pitch = 0;
96 int32_t flags = 0;
97
99 RageSurface(const RageSurface& cpy);
100 ~RageSurface();
101};
102
103auto
104CreateSurface(int width,
105 int height,
106 int bpp,
107 uint32_t Rmask,
108 uint32_t Gmask,
109 uint32_t Bmask,
110 uint32_t Amask) -> RageSurface*;
111auto
112CreateSurfaceFrom(int width,
113 int height,
114 int bpp,
115 uint32_t Rmask,
116 uint32_t Gmask,
117 uint32_t Bmask,
118 uint32_t Amask,
119 uint8_t* pPixels,
120 uint32_t pitch) -> RageSurface*;
121
122#endif
Definition RageSurface.h:8
Definition RageSurface.h:51
Definition RageSurface.h:39
Definition RageSurface.h:90