2 #include "oxygine-include.h" 10 void copy(
const ImageData& src,
const ImageData& dest);
13 void move(
const ImageData& src,
const ImageData& dest);
15 void blit(
const ImageData& src,
const ImageData& dest);
16 void blitColored(
const ImageData& src,
const ImageData& dest,
const Color& c);
17 void blitPremultiply(
const ImageData& src,
const ImageData& dest);
18 void premultiply(
const ImageData& dest);
19 void flipY(
const ImageData& src,
const ImageData& dest);
20 void blend(
const ImageData& src,
const ImageData& dest);
22 inline void blend_srcAlpha_invSrcAlpha(
const Pixel& pS, Pixel& pD)
24 const unsigned int& s = pS.rgba;
25 unsigned int& d = pD.rgba;
27 unsigned int dst_rb = d & 0xFF00FF;
28 unsigned int dst_ag = (d >> 8) & 0xFF00FF;
30 unsigned int src_rb = s & 0xFF00FF;
31 unsigned int src_ag = (s >> 8) & 0xFF00FF;
33 unsigned int d_rb = src_rb - dst_rb;
34 unsigned int d_ag = src_ag - dst_ag;
41 const unsigned int rb = (d_rb + dst_rb) & 0x00FF00FF;
42 const unsigned int ag = ((d_ag + dst_ag) << 8) & 0xFF00FF00;
49 void applyOperation(
const Op& op,
const ImageData& src,
const ImageData& dest);
55 op_fill() {color.rgba = 0xffffffff;}
59 template<
class Src,
class Dest>
60 void operator()(
const Src& s, Dest& d,
const unsigned char* srcData,
unsigned char* destData)
const 62 d.setPixel(destData, color);
71 template<
class Src,
class Dest>
72 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 80 int v = rand() % 1000;
82 p.r = p.g = p.b = p.a = v > _v ? 255 : 0;
85 destPixelFormat.setPixel(destData, p);
94 template<
class Src,
class Dest>
95 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 98 srcPixelFormat.getPixel(srcData, p);
101 unsigned char na = destPixelFormat.snap_a(p.a);
103 p.r = (p.r * na) / 255;
104 p.g = (p.g * na) / 255;
105 p.b = (p.b * na) / 255;
107 destPixelFormat.setPixel(destData, p);
114 template<
class Src,
class Dest>
115 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 118 srcPixelFormat.getPixel(srcData, p);
119 destPixelFormat.setPixel(destData, p);
128 template<
class Src,
class Dest>
129 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 132 srcPixelFormat.getPixel(srcData, src);
135 dest.r = (src.r * color.r) / 255;
136 dest.g = (src.g * color.g) / 255;
137 dest.b = (src.b * color.b) / 255;
138 dest.a = (src.a * color.a) / 255;
140 destPixelFormat.setPixel(destData, dest);
151 template<
class Src,
class Dest>
152 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 155 srcPixelFormat.getPixel(srcData, s);
158 destPixelFormat.getPixel(destData, d);
160 #define M(v) std::min(v, 255); 161 unsigned char a = s.a;
162 unsigned char ia = 255 - a;
164 r.r = M((d.r * ia) / 255 + (s.r * a) / 255);
165 r.g = M((d.g * ia) / 255 + (s.g * a) / 255);
166 r.b = M((d.b * ia) / 255 + (s.b * a) / 255);
167 r.a = M((d.a * ia) / 255 + (s.a * a) / 255);
170 destPixelFormat.setPixel(destData, r);
178 template<
class Src,
class Dest>
179 void operator()(
const Src& srcPixelFormat, Dest& destPixelFormat,
const unsigned char* srcData,
unsigned char* destData)
const 182 srcPixelFormat.getPixel(srcData, pS);
185 destPixelFormat.getPixel(destData, pD);
187 blend_srcAlpha_invSrcAlpha(pS, pD);
188 destPixelFormat.setPixel(destData, pD);
196 template <
class Op,
class Src,
class Dest>
197 void applyOperationT(
const Op& op,
const Src& srcPixelFormat, Dest& destPixelFormat,
const ImageData& src,
const ImageData& dest)
199 if (!check(src, dest))
202 const unsigned char* srcBuffer = (
unsigned char*)src.data;
203 unsigned char* destBuffer = (
unsigned char*)dest.data;
208 for (
int y = 0; y != h; ++y)
210 const unsigned char* srcLine = srcBuffer;
211 unsigned char* destLine = destBuffer;
213 for (
int x = 0; x != w; ++x)
215 op(srcPixelFormat, destPixelFormat, srcLine, destLine);
217 destLine += dest.bytespp;
218 srcLine += src.bytespp;
221 srcBuffer += src.pitch;
222 destBuffer += dest.pitch;
227 template <
class Op,
class Dest>
228 void applyOperationT(
const Op& op, Dest& destPixelFormat,
const ImageData& dest)
230 if (!check(dest, dest))
233 unsigned char* destBuffer = (
unsigned char*)dest.data;
238 for (
int y = 0; y != h; ++y)
240 unsigned char* destLine = destBuffer;
242 for (
int x = 0; x != w; ++x)
244 op(destPixelFormat, destPixelFormat, destLine, destLine);
245 destLine += dest.bytespp;
248 destBuffer += dest.pitch;
255 #define FORMAT_OP1(format) case TF_##format: \ 258 applyOperationT(op, s, d, src, dest); \ 262 template<
class Src,
class Op>
263 void SwitchSrcDestT(
const Op& op,
const Src& s,
const ImageData& src,
const ImageData& dest)
265 #define FORMAT_CASE FORMAT_OP1 266 ALL_FORMATS_SWITCH(dest.format);
271 #define FORMAT_OP2(format) case TF_##format: \ 274 SwitchSrcDestT(op, s, src, dest); \ 280 void applyOperation(
const Op& op,
const ImageData& src,
const ImageData& dest)
282 #define FORMAT_CASE FORMAT_OP2 283 ALL_FORMATS_SWITCH(src.format);
288 #define FORMAT_OP3(format) case TF_##format: \ 291 applyOperationT(op, d, dest); \ 296 void applyOperation(
const Op& op,
const ImageData& dest)
298 #define FORMAT_CASE FORMAT_OP3 299 ALL_FORMATS_SWITCH(dest.format);
Definition: ImageDataOperations.h:175
Definition: ImageDataOperations.h:91
Definition: ImageData.h:54
–oxgl-end–!
Definition: Actor.h:14
Definition: ImageDataOperations.h:123
Definition: ImageDataOperations.h:66
Definition: ImageDataOperations.h:148
Definition: ImageDataOperations.h:52
Definition: ImageDataOperations.h:111