Etterna 0.74.4
Loading...
Searching...
No Matches
RageSurfaceUtils.h
1/* Utility functions for RageSurfaces. */
2
3#ifndef RAGE_SURFACE_UTILS_H
4#define RAGE_SURFACE_UTILS_H
5
9struct RageSurface;
10struct RageColor;
11
13namespace RageSurfaceUtils {
14auto
15decodepixel(const uint8_t* p, int bpp) -> uint32_t;
16void
17encodepixel(uint8_t* p, int bpp, uint32_t pixel);
18
19void
20GetRawRGBAV(uint32_t pixel, const RageSurfaceFormat& fmt, uint8_t* v);
21void
22GetRawRGBAV(const uint8_t* p, const RageSurfaceFormat& fmt, uint8_t* v);
23void
24GetRGBAV(uint32_t pixel, const RageSurface* src, uint8_t* v);
25void
26GetRGBAV(const uint8_t* p, const RageSurface* src, uint8_t* v);
27
28auto
29SetRawRGBAV(const RageSurfaceFormat& fmt, const uint8_t* v) -> uint32_t;
30void
31SetRawRGBAV(uint8_t* p, const RageSurface* src, const uint8_t* v);
32auto
33SetRGBAV(const RageSurfaceFormat& fmt, const uint8_t* v) -> uint32_t;
34void
35SetRGBAV(uint8_t* p, const RageSurface* src, const uint8_t* v);
36
37/* Get the number of bits representing each color channel in fmt. */
38void
39GetBitsPerChannel(const RageSurfaceFormat& fmt, uint32_t bits[4]);
40
41void
42CopySurface(const RageSurface* src, RageSurface* dest);
43auto
44ConvertSurface(const RageSurface* src,
45 RageSurface*& dst,
46 int width,
47 int height,
48 int bpp,
49 uint32_t R,
50 uint32_t G,
51 uint32_t B,
52 uint32_t A) -> bool;
53void
54ConvertSurface(RageSurface*& image,
55 int width,
56 int height,
57 int bpp,
58 uint32_t R,
59 uint32_t G,
60 uint32_t B,
61 uint32_t A);
62
63const RageColor
64GetAverageRGB(const RageSurface* img, unsigned pixelIncrement = 1);
65
66void
67FixHiddenAlpha(RageSurface* img);
68
69auto
70FindSurfaceTraits(const RageSurface* img) -> int;
71
72/* The surface contains no transparent pixels and/or never uses its color
73 * key, so it doesn't need any alpha bits at all. */
74enum
75{
76 TRAIT_NO_TRANSPARENCY = 0x0001
77}; /* 0alpha */
78
79/* The surface contains only transparent values of 0 or 1; no translucency.
80 * It only needs one bit of alpha. */
81enum
82{
83 TRAIT_BOOL_TRANSPARENCY = 0x0002
84}; /* 1alpha */
85
86void
87BlitTransform(const RageSurface* src,
88 RageSurface* dst,
89 const float fCoords[8] /* TL, BR, BL, TR */);
90
91void
92Blit(const RageSurface* src, RageSurface* dst, int width = -1, int height = -1);
93void
94CorrectBorderPixels(RageSurface* img, int width, int height);
95
96auto
97SaveSurface(const RageSurface* img, const std::string& file) -> bool;
98auto
99LoadSurface(const std::string& file) -> RageSurface*;
100
101/* Quickly palettize to an gray/alpha texture. */
102auto
103PalettizeToGrayscale(const RageSurface* src_surf, int GrayBits, int AlphaBits)
104 -> RageSurface*;
105
106auto
107MakeDummySurface(int height, int width) -> RageSurface*;
108
109void
110ApplyHotPinkColorKey(RageSurface*& img);
111void
112FlipVertically(RageSurface* img);
113} // namespace RageSurfaceUtils;
114
115#endif
Utility functions for the RageSurfaces.
Definition RageSurface_Load.h:7
Definition RageTypes.h:332
Definition RageSurface.h:8
Definition RageSurface.h:51
Definition RageSurface.h:39
Definition RageSurface.h:90