23 uint t = (((x & 0x07e0)*
m_alpha255) >> 8) & 0x07e0;
24 t |= (((x & 0xf81f)*(
m_alpha255>>2)) >> 6) & 0xf81f;
33
34
37 inline void write(quint16 *dst, quint16 src) { *dst = src; }
44 m_alpha = (alpha * 255) >> 8;
45 m_ialpha = 255 - m_alpha;
48 inline void write(quint16 *dst, quint16 src) {
49 *dst = BYTE_MUL_RGB16(src, m_alpha) + BYTE_MUL_RGB16(*dst, m_ialpha);
59 inline void write(quint16 *dst, quint32 src) {
60 const quint8 alpha = qAlpha(src);
62 quint16 s = qConvertRgb32To16(src);
64 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
74 m_alpha = (alpha * 255) >> 8;
77 inline void write(quint16 *dst, quint32 src) {
78 src = BYTE_MUL(src, m_alpha);
79 const quint8 alpha = qAlpha(src);
81 quint16 s = qConvertRgb32To16(src);
83 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
94 const uchar *srcPixels,
int sbpl,
int srch,
95 const QRectF &targetRect,
96 const QRectF &sourceRect,
101 printf(
"qt_scale_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
102 destPixels, dbpl, srcPixels, sbpl,
103 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
104 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
107 if (const_alpha == 256) {
109 qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch,
110 targetRect, sourceRect, clip, noAlpha);
113 qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch,
114 targetRect, sourceRect, clip, constAlpha);
119 const uchar *srcPixels,
int sbpl,
int srch,
120 const QRectF &targetRect,
121 const QRectF &sourceRect,
126 printf(
"qt_scale_argb32_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
127 destPixels, dbpl, srcPixels, sbpl,
128 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
129 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
132 if (const_alpha == 256) {
134 qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch,
135 targetRect, sourceRect, clip, noAlpha);
138 qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch,
139 targetRect, sourceRect, clip, constAlpha);
144 const uchar *src,
int sbpl,
149 printf(
"qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
150 dst, dbpl, src, sbpl, w, h, const_alpha);
153 if (const_alpha == 256) {
156 memcpy(dst, src, length);
160 }
else if (const_alpha != 0) {
161 quint16 *d = (quint16 *) dst;
162 const quint16 *s = (
const quint16 *) src;
163 quint8 a = (255 * const_alpha) >> 8;
166 for (
int x=0; x<w; ++x) {
167 d[x] = BYTE_MUL_RGB16(s[x], a) + BYTE_MUL_RGB16(d[x], ia);
169 d = (quint16 *)(((uchar *) d) + dbpl);
170 s = (
const quint16 *)(((
const uchar *) s) + sbpl);
177 const uchar *srcPixels,
int sbpl,
181 quint16 *dst = (quint16 *) destPixels;
182 const quint32 *src = (
const quint32 *) srcPixels;
184 const_alpha = (const_alpha * 255) >> 8;
185 for (
int y=0; y<h; ++y) {
186 for (
int i = 0; i < w; ++i) {
188 s = BYTE_MUL(s, const_alpha);
189 int alpha = qAlpha(s);
190 s = qConvertRgb32To16(s);
191 s += BYTE_MUL_RGB16(dst[i], 255 - alpha);
194 dst = (quint16 *)(((uchar *) dst) + dbpl);
195 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
200 const uchar *srcPixels,
int sbpl,
204 if (const_alpha != 256) {
205 qt_blend_argb32_on_rgb16_const_alpha(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
209 quint16 *dst = (quint16 *) destPixels;
210 const quint32 *src = (
const quint32 *) srcPixels;
212 for (
int y=0; y<h; ++y) {
213 for (
int x=0; x<w; ++x) {
215 quint32 spix = src[x];
216 quint32 alpha = spix >> 24;
219 dst[x] = qConvertRgb32To16(spix);
220 }
else if (alpha != 0) {
221 quint32 dpix = dst[x];
223 quint32 sia = 255 - alpha;
225 quint32 sr = (spix >> 8) & 0xf800;
226 quint32 sg = (spix >> 5) & 0x07e0;
227 quint32 sb = (spix >> 3) & 0x001f;
229 quint32 dr = (dpix & 0x0000f800);
230 quint32 dg = (dpix & 0x000007e0);
231 quint32 db = (dpix & 0x0000001f);
233 quint32 siar = dr * sia;
234 quint32 siag = dg * sia;
235 quint32 siab = db * sia;
237 quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8);
238 quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8);
239 quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
241 dst[x] = (rr & 0xf800)
246 dst = (quint16 *) (((uchar *) dst) + dbpl);
247 src = (
const quint32 *) (((
const uchar *) src) + sbpl);
253 const uchar *srcPixels,
int sbpl,
258 printf(
"qt_blend_rgb32_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
259 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
262 if (const_alpha != 256) {
263 qt_blend_argb32_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
267 const quint32 *src = (
const quint32 *) srcPixels;
268 int srcExtraStride = (sbpl >> 2) - w;
270 int dstJPL = dbpl / 2;
272 quint16 *dst = (quint16 *) destPixels;
273 quint16 *dstEnd = dst + dstJPL * h;
275 int dstExtraStride = dstJPL - w;
277 while (dst < dstEnd) {
278 const quint32 *srcEnd = src + w;
279 while (src < srcEnd) {
280 *dst = qConvertRgb32To16(*src);
284 dst += dstExtraStride;
285 src += srcExtraStride;
292
293
296 const uchar *srcPixels,
int sbpl,
301 fprintf(stdout,
"qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
302 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
306 const uint *src = (
const uint *) srcPixels;
307 uint *dst = (uint *) destPixels;
308 if (const_alpha == 256) {
309 for (
int y=0; y<h; ++y) {
310 for (
int x=0; x<w; ++x) {
315 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
317 dst = (quint32 *)(((uchar *) dst) + dbpl);
318 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
320 }
else if (const_alpha != 0) {
321 const_alpha = (const_alpha * 255) >> 8;
322 for (
int y=0; y<h; ++y) {
323 for (
int x=0; x<w; ++x) {
324 uint s = BYTE_MUL(src[x], const_alpha);
325 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
327 dst = (quint32 *)(((uchar *) dst) + dbpl);
328 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
335 const uchar *srcPixels,
int sbpl,
340 fprintf(stdout,
"qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
341 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
344 const uint *src = (
const uint *) srcPixels;
345 uint *dst = (uint *) destPixels;
346 if (const_alpha == 256) {
347 const int len = w * 4;
348 for (
int y = 0; y < h; ++y) {
349 memcpy(dst, src, len);
350 dst = (quint32 *)(((uchar *) dst) + dbpl);
351 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
354 }
else if (const_alpha != 0) {
355 const_alpha = (const_alpha * 255) >> 8;
356 int ialpha = 255 - const_alpha;
357 for (
int y=0; y<h; ++y) {
358 for (
int x=0; x<w; ++x)
359 dst[x] = INTERPOLATE_PIXEL_255(dst[x], ialpha, src[x], const_alpha);
360 dst = (quint32 *)(((uchar *) dst) + dbpl);
361 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
367 inline void write(quint32 *dst, quint32 src) { *dst = src; }
374 m_alpha = (alpha * 255) >> 8;
375 m_ialpha = 255 - m_alpha;
378 inline void write(quint32 *dst, quint32 src) {
379 *dst = INTERPOLATE_PIXEL_255(src, m_alpha, *dst, m_ialpha);
389 inline void write(quint32 *dst, quint32 src)
391 blend_pixel(*dst, src);
400 m_alpha = (alpha * 255) >> 8;
403 inline void write(quint32 *dst, quint32 src)
405 blend_pixel(*dst, src, m_alpha);
414 const uchar *srcPixels,
int sbpl,
int srch,
415 const QRectF &targetRect,
416 const QRectF &sourceRect,
421 printf(
"qt_scale_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
422 destPixels, dbpl, srcPixels, sbpl,
423 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
424 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
427 if (const_alpha == 256) {
429 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
430 targetRect, sourceRect, clip, noAlpha);
433 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
434 targetRect, sourceRect, clip, constAlpha);
439 const uchar *srcPixels,
int sbpl,
int srch,
440 const QRectF &targetRect,
441 const QRectF &sourceRect,
446 printf(
"qt_scale_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
447 destPixels, dbpl, srcPixels, sbpl,
448 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
449 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
452 if (const_alpha == 256) {
454 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
455 targetRect, sourceRect, clip, sourceAlpha);
458 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
459 targetRect, sourceRect, clip, constAlpha);
464 const uchar *srcPixels,
int sbpl,
465 const QRectF &targetRect,
466 const QRectF &sourceRect,
468 const QTransform &targetRectTransform,
471 if (const_alpha == 256) {
473 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
474 reinterpret_cast<
const quint16 *>(srcPixels), sbpl,
475 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
478 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
479 reinterpret_cast<
const quint16 *>(srcPixels), sbpl,
480 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
485 const uchar *srcPixels,
int sbpl,
486 const QRectF &targetRect,
487 const QRectF &sourceRect,
489 const QTransform &targetRectTransform,
492 if (const_alpha == 256) {
494 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
495 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
496 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
499 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
500 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
501 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
507 const uchar *srcPixels,
int sbpl,
508 const QRectF &targetRect,
509 const QRectF &sourceRect,
511 const QTransform &targetRectTransform,
514 if (const_alpha == 256) {
516 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
517 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
518 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
521 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
522 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
523 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
528 const uchar *srcPixels,
int sbpl,
529 const QRectF &targetRect,
530 const QRectF &sourceRect,
532 const QTransform &targetRectTransform,
535 if (const_alpha == 256) {
537 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
538 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
539 targetRect, sourceRect, clip, targetRectTransform, sourceAlpha);
542 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
543 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
544 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
554 qScaleFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32;
555 qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32;
556 qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32;
557 qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32;
558 qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16;
559 qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16;
560#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
561 qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32;
562 qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32;
563 qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32;
564 qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32;
567 qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32;
568 qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32;
569 qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32;
570 qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32;
571 qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb16;
572 qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16;
573 qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16;
574#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
575 qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32;
576 qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32;
577 qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32;
578 qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32;
581 qTransformFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32;
582 qTransformFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32;
583 qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32;
584 qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32;
585 qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16;
586 qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16;
587#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
588 qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32;
589 qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_transform_image_argb32_on_argb32;
590 qTransformFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32;
591 qTransformFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_transform_image_argb32_on_argb32;
Combined button and popup list for selecting options.
SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qInitBlendFunctions()
void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_transform_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_scale_image_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
void qt_transform_image_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl, const uchar *src, int sbpl, int w, int h, int const_alpha)
static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void(* SrcOverBlendFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, int w, int h, int const_alpha)
void(* SrcOverScaleFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clipRect, int const_alpha)
void(* SrcOverTransformFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clipRect, const QTransform &targetRectTransform, int const_alpha)
void write(quint32 *dst, quint32 src)
Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha)
void write(quint32 *dst, quint32 src)
void write(quint16 *dst, quint32 src)
Blend_ARGB32_on_RGB16_SourceAndConstAlpha(quint32 alpha)
void write(quint16 *dst, quint32 src)
void write(quint16 *dst, quint16 src)
Blend_RGB16_on_RGB16_ConstAlpha(quint32 alpha)
void write(quint16 *dst, quint16 src)
Blend_RGB32_on_RGB32_ConstAlpha(quint32 alpha)
void write(quint32 *dst, quint32 src)
void write(quint32 *dst, quint32 src)
quint16 bytemul(quint16 x) const
uchar alpha(uchar src) const
SourceAndConstAlpha(int a)
quint16 bytemul(quint16 spix) const
uchar alpha(uchar src) const