12 #ifndef BLITTER_32BPP_BASE_HPP 
   13 #define BLITTER_32BPP_BASE_HPP 
   16 #include "../core/bitmath_func.hpp" 
   17 #include "../core/math_func.hpp" 
   18 #include "../gfx_func.h" 
   24    void *
MoveTo(
void *video, 
int x, 
int y);
 
   25    void SetPixel(
void *video, 
int x, 
int y, uint8 colour);
 
   26    void DrawRect(
void *video, 
int width, 
int height, uint8 colour);
 
   27    void CopyFromBuffer(
void *video, 
const void *src, 
int width, 
int height);
 
   28    void CopyToBuffer(
const void *video, 
void *dst, 
int width, 
int height);
 
   29    void CopyImageToBuffer(
const void *video, 
void *dst, 
int width, 
int height, 
int dst_pitch);
 
   30    void ScrollBuffer(
void *video, 
int &left, 
int &top, 
int &width, 
int &height, 
int scroll_x, 
int scroll_y);
 
   55               ((
int)(r - cr) * a) / 256 + cr,
 
   56               ((
int)(g - cg) * a) / 256 + cg,
 
   57               ((
int)(b - cb) * a) / 256 + cb);
 
   66     if (a == 0) 
return current;
 
   67     if (a >= 255) 
return Colour(r, g, b);
 
   90     if (a == 0) 
return current;
 
  112     return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
 
  122   static inline uint8 
MakeDark(uint8 r, uint8 g, uint8 b)
 
  125     return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
 
  142     uint grey = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
 
  144     return Colour(grey, grey, grey);
 
  147   static const int DEFAULT_BRIGHTNESS = 128;
 
  149   static inline Colour AdjustBrightness(
Colour colour, uint8 brightness)
 
  152     if (brightness == DEFAULT_BRIGHTNESS) 
return colour;
 
  155     uint16 r = colour.r * brightness / DEFAULT_BRIGHTNESS;
 
  156     uint16 g = colour.g * brightness / DEFAULT_BRIGHTNESS;
 
  157     uint16 b = colour.b * brightness / DEFAULT_BRIGHTNESS;
 
  160     if (r > 255) ob += r - 255;
 
  161     if (g > 255) ob += g - 255;
 
  162     if (b > 255) ob += b - 255;
 
  164     if (ob == 0) 
return Colour(r, g, b, colour.
a);
 
  169                          r >= 255 ? 255 : 
min(r + ob * (255 - r) / 256, 255),
 
  170                          g >= 255 ? 255 : 
min(g + ob * (255 - g) / 256, 255),
 
  171                          b >= 255 ? 255 : 
min(b + ob * (255 - b) / 256, 255),