22 #ifndef ULTIMA4_GFX_IMAGE_H 23 #define ULTIMA4_GFX_IMAGE_H 25 #include "ultima/ultima4/core/types.h" 26 #include "ultima/ultima4/gfx/textcolor.h" 27 #include "graphics/managed_surface.h" 34 #define DARK_GRAY_HALO RGBA(14,15,16,255) 37 RGBA(
int red,
int green,
int blue,
int alpha) : r(red), g(green), b(blue), a(alpha) {}
38 RGBA() : r(0), g(0), b(0), a(255) {}
41 operator uint32()
const {
42 return r | (g << 8) | (b << 16) | (0xff << 24);
45 bool operator==(
const RGBA &lhs,
const RGBA &rhs);
54 #define IM_OPAQUE (uint) 255 55 #define IM_TRANSPARENT 0 68 DisposeAfterUse::Flag _disposeAfterUse;
70 RGBA _backgroundColor;
79 uint getColor(byte r, byte g, byte b, byte a);
85 static Image *create(
int w,
int h);
96 static Image *createScreenImage();
114 void setPalette(
const byte *colors,
unsigned n_colors);
119 void setPaletteFromImage(
const Image *src);
120 bool getTransparentIndex(uint &index)
const;
121 void performTransparencyHack(uint colorValue, uint numFrames, uint currentFrameIndex, uint haloWidth, uint haloOpacityIncrementByPixelDistance);
122 void setTransparentIndex(uint index);
127 bool setFontColor(ColorFG fg, ColorBG bg);
132 bool setFontColorFG(ColorFG fg);
137 bool setFontColorBG(ColorBG bg);
142 RGBA getPaletteColor(
int index);
147 bool setPaletteIndex(uint index, uint8 r, uint8 g, uint8 b);
149 RGBA setColor(uint8 r, uint8 g, uint8 b, uint8 a = IM_OPAQUE);
153 bool isAlphaOn()
const;
159 void initializeToBackgroundColor(
RGBA backgroundColor = DARK_GRAY_HALO);
161 void makeBackgroundColorTransparent(
int haloSize = 0,
int shadowOpacity = 255);
171 void putPixel(
int x,
int y,
int r,
int g,
int b,
int a);
178 void putPixelIndex(
int x,
int y, uint index);
183 void fillRect(
int x,
int y,
int w,
int h,
int r,
int g,
int b,
int a = IM_OPAQUE);
191 void getPixel(
int x,
int y, uint &r, uint &g, uint &b, uint &a)
const;
198 void getPixelIndex(
int x,
int y, uint &index)
const;
204 void draw(
int x,
int y)
const {
205 drawOn(
nullptr, x, y);
213 void drawSubRect(
int x,
int y,
int rx,
int ry,
int rw,
int rh)
const {
214 drawSubRectOn(
nullptr, x, y, rx, ry, rw, rh);
223 drawSubRectInvertedOn(
nullptr, x, y, rx, ry, rw, rh);
230 void drawOn(
Image *d,
int x,
int y)
const;
235 void drawSubRectOn(
Image *d,
int x,
int y,
int rx,
int ry,
int rw,
int rh)
const;
240 void drawSubRectInvertedOn(
Image *d,
int x,
int y,
int rx,
int ry,
int rw,
int rh)
const;
251 bool isIndexed()
const {
254 BackendSurface getSurface() {
258 void drawHighlighted();
Definition: managed_surface.h:51
int16 & w
Definition: managed_surface.h:117
void drawSubRect(int x, int y, int rx, int ry, int rw, int rh) const
Definition: image.h:213
Definition: detection.h:27
void drawSubRectInverted(int x, int y, int rx, int ry, int rw, int rh) const
Definition: image.h:222
int16 & h
Definition: managed_surface.h:118
PixelFormat & format
Definition: managed_surface.h:120
Definition: movie_decoder.h:32
void draw(int x, int y) const
Definition: image.h:204