24 uint t = (((x & 0x07e0)*
m_alpha255) >> 8) & 0x07e0;
25 t |= (((x & 0xf81f)*(
m_alpha255>>2)) >> 6) & 0xf81f;
34
35
38 inline void write(quint16 *dst, quint16 src) { *dst = src; }
45 m_alpha = (alpha * 255) >> 8;
46 m_ialpha = 255 - m_alpha;
49 inline void write(quint16 *dst, quint16 src) {
50 *dst = BYTE_MUL_RGB16(src, m_alpha) + BYTE_MUL_RGB16(*dst, m_ialpha);
60 inline void write(quint16 *dst, quint32 src) {
61 const quint8 alpha = qAlpha(src);
63 quint16 s = qConvertRgb32To16(src);
65 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
75 m_alpha = (alpha * 255) >> 8;
78 inline void write(quint16 *dst, quint32 src) {
79 src = BYTE_MUL(src, m_alpha);
80 const quint8 alpha = qAlpha(src);
82 quint16 s = qConvertRgb32To16(src);
84 s += BYTE_MUL_RGB16(*dst, 255 - alpha);
95 const uchar *srcPixels,
int sbpl,
int srch,
96 const QRectF &targetRect,
97 const QRectF &sourceRect,
102 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",
103 destPixels, dbpl, srcPixels, sbpl,
104 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
105 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
108 if (const_alpha == 256) {
110 qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch,
111 targetRect, sourceRect, clip, noAlpha);
114 qt_scale_image_16bit<quint16>(destPixels, dbpl, srcPixels, sbpl, srch,
115 targetRect, sourceRect, clip, constAlpha);
120 const uchar *srcPixels,
int sbpl,
int srch,
121 const QRectF &targetRect,
122 const QRectF &sourceRect,
127 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",
128 destPixels, dbpl, srcPixels, sbpl,
129 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
130 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
133 if (const_alpha == 256) {
135 qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch,
136 targetRect, sourceRect, clip, noAlpha);
139 qt_scale_image_16bit<quint32>(destPixels, dbpl, srcPixels, sbpl, srch,
140 targetRect, sourceRect, clip, constAlpha);
145 const uchar *src,
int sbpl,
150 printf(
"qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
151 dst, dbpl, src, sbpl, w, h, const_alpha);
154 if (const_alpha == 256) {
157 memcpy(dst, src, length);
161 }
else if (const_alpha != 0) {
162 quint16 *d = (quint16 *) dst;
163 const quint16 *s = (
const quint16 *) src;
164 quint8 a = (255 * const_alpha) >> 8;
167 for (
int x=0; x<w; ++x) {
168 d[x] = BYTE_MUL_RGB16(s[x], a) + BYTE_MUL_RGB16(d[x], ia);
170 d = (quint16 *)(((uchar *) d) + dbpl);
171 s = (
const quint16 *)(((
const uchar *) s) + sbpl);
178 const uchar *srcPixels,
int sbpl,
182 quint16 *dst = (quint16 *) destPixels;
183 const quint32 *src = (
const quint32 *) srcPixels;
185 const_alpha = (const_alpha * 255) >> 8;
186 for (
int y=0; y<h; ++y) {
187 for (
int i = 0; i < w; ++i) {
189 s = BYTE_MUL(s, const_alpha);
190 int alpha = qAlpha(s);
191 s = qConvertRgb32To16(s);
192 s += BYTE_MUL_RGB16(dst[i], 255 - alpha);
195 dst = (quint16 *)(((uchar *) dst) + dbpl);
196 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
201 const uchar *srcPixels,
int sbpl,
205 if (const_alpha != 256) {
206 qt_blend_argb32_on_rgb16_const_alpha(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
210 quint16 *dst = (quint16 *) destPixels;
211 const quint32 *src = (
const quint32 *) srcPixels;
213 for (
int y=0; y<h; ++y) {
214 for (
int x=0; x<w; ++x) {
216 quint32 spix = src[x];
217 quint32 alpha = spix >> 24;
220 dst[x] = qConvertRgb32To16(spix);
221 }
else if (alpha != 0) {
222 quint32 dpix = dst[x];
224 quint32 sia = 255 - alpha;
226 quint32 sr = (spix >> 8) & 0xf800;
227 quint32 sg = (spix >> 5) & 0x07e0;
228 quint32 sb = (spix >> 3) & 0x001f;
230 quint32 dr = (dpix & 0x0000f800);
231 quint32 dg = (dpix & 0x000007e0);
232 quint32 db = (dpix & 0x0000001f);
234 quint32 siar = dr * sia;
235 quint32 siag = dg * sia;
236 quint32 siab = db * sia;
238 quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8);
239 quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8);
240 quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
242 dst[x] = (rr & 0xf800)
247 dst = (quint16 *) (((uchar *) dst) + dbpl);
248 src = (
const quint32 *) (((
const uchar *) src) + sbpl);
254 const uchar *srcPixels,
int sbpl,
259 printf(
"qt_blend_rgb32_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
260 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
263 if (const_alpha != 256) {
264 qt_blend_argb32_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
268 const quint32 *src = (
const quint32 *) srcPixels;
269 int srcExtraStride = (sbpl >> 2) - w;
271 int dstJPL = dbpl / 2;
273 quint16 *dst = (quint16 *) destPixels;
274 quint16 *dstEnd = dst + dstJPL * h;
276 int dstExtraStride = dstJPL - w;
278 while (dst < dstEnd) {
279 const quint32 *srcEnd = src + w;
280 while (src < srcEnd) {
281 *dst = qConvertRgb32To16(*src);
285 dst += dstExtraStride;
286 src += srcExtraStride;
293
294
297 const uchar *srcPixels,
int sbpl,
302 fprintf(stdout,
"qt_blend_argb32_on_argb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
303 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
307 const uint *src = (
const uint *) srcPixels;
308 uint *dst = (uint *) destPixels;
309 if (const_alpha == 256) {
310 for (
int y=0; y<h; ++y) {
311 for (
int x=0; x<w; ++x) {
316 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
318 dst = (quint32 *)(((uchar *) dst) + dbpl);
319 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
321 }
else if (const_alpha != 0) {
322 const_alpha = (const_alpha * 255) >> 8;
323 for (
int y=0; y<h; ++y) {
324 for (
int x=0; x<w; ++x) {
325 uint s = BYTE_MUL(src[x], const_alpha);
326 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
328 dst = (quint32 *)(((uchar *) dst) + dbpl);
329 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
336 const uchar *srcPixels,
int sbpl,
341 fprintf(stdout,
"qt_blend_rgb32_on_rgb32: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
342 destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
345 const uint *src = (
const uint *) srcPixels;
346 uint *dst = (uint *) destPixels;
347 if (const_alpha == 256) {
348 const int len = w * 4;
349 for (
int y = 0; y < h; ++y) {
350 memcpy(dst, src, len);
351 dst = (quint32 *)(((uchar *) dst) + dbpl);
352 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
355 }
else if (const_alpha != 0) {
356 const_alpha = (const_alpha * 255) >> 8;
357 int ialpha = 255 - const_alpha;
358 for (
int y=0; y<h; ++y) {
359 for (
int x=0; x<w; ++x)
360 dst[x] = INTERPOLATE_PIXEL_255(dst[x], ialpha, src[x], const_alpha);
361 dst = (quint32 *)(((uchar *) dst) + dbpl);
362 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
368 inline void write(quint32 *dst, quint32 src) { *dst = src; }
375 m_alpha = (alpha * 255) >> 8;
376 m_ialpha = 255 - m_alpha;
379 inline void write(quint32 *dst, quint32 src) {
380 *dst = INTERPOLATE_PIXEL_255(src, m_alpha, *dst, m_ialpha);
390 inline void write(quint32 *dst, quint32 src)
392 blend_pixel(*dst, src);
401 m_alpha = (alpha * 255) >> 8;
404 inline void write(quint32 *dst, quint32 src)
406 blend_pixel(*dst, src, m_alpha);
415 const uchar *srcPixels,
int sbpl,
int srch,
416 const QRectF &targetRect,
417 const QRectF &sourceRect,
422 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",
423 destPixels, dbpl, srcPixels, sbpl,
424 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
425 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
428 if (const_alpha == 256) {
430 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
431 targetRect, sourceRect, clip, noAlpha);
434 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
435 targetRect, sourceRect, clip, constAlpha);
440 const uchar *srcPixels,
int sbpl,
int srch,
441 const QRectF &targetRect,
442 const QRectF &sourceRect,
447 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",
448 destPixels, dbpl, srcPixels, sbpl,
449 targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
450 sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
453 if (const_alpha == 256) {
455 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
456 targetRect, sourceRect, clip, sourceAlpha);
459 qt_scale_image_32bit(destPixels, dbpl, srcPixels, sbpl, srch,
460 targetRect, sourceRect, clip, constAlpha);
465 const uchar *srcPixels,
int sbpl,
466 const QRectF &targetRect,
467 const QRectF &sourceRect,
469 const QTransform &targetRectTransform,
472 if (const_alpha == 256) {
474 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
475 reinterpret_cast<
const quint16 *>(srcPixels), sbpl,
476 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
479 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
480 reinterpret_cast<
const quint16 *>(srcPixels), sbpl,
481 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
486 const uchar *srcPixels,
int sbpl,
487 const QRectF &targetRect,
488 const QRectF &sourceRect,
490 const QTransform &targetRectTransform,
493 if (const_alpha == 256) {
495 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
496 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
497 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
500 qt_transform_image(
reinterpret_cast<quint16 *>(destPixels), dbpl,
501 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
502 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
508 const uchar *srcPixels,
int sbpl,
509 const QRectF &targetRect,
510 const QRectF &sourceRect,
512 const QTransform &targetRectTransform,
515 if (const_alpha == 256) {
517 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
518 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
519 targetRect, sourceRect, clip, targetRectTransform, noAlpha);
522 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
523 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
524 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
529 const uchar *srcPixels,
int sbpl,
530 const QRectF &targetRect,
531 const QRectF &sourceRect,
533 const QTransform &targetRectTransform,
536 if (const_alpha == 256) {
538 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
539 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
540 targetRect, sourceRect, clip, targetRectTransform, sourceAlpha);
543 qt_transform_image(
reinterpret_cast<quint32 *>(destPixels), dbpl,
544 reinterpret_cast<
const quint32 *>(srcPixels), sbpl,
545 targetRect, sourceRect, clip, targetRectTransform, constAlpha);
555 qScaleFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32;
556 qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32;
557 qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_scale_image_rgb32_on_rgb32;
558 qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32;
559 qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16;
560 qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16;
561#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
562 qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32;
563 qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32;
564 qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_scale_image_rgb32_on_rgb32;
565 qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32;
568 qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32;
569 qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32;
570 qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32;
571 qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32;
572 qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb16;
573 qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16;
574 qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16;
575#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
576 qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32;
577 qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32;
578 qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32;
579 qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32;
582 qTransformFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32;
583 qTransformFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32;
584 qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_transform_image_rgb32_on_rgb32;
585 qTransformFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_argb32;
586 qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16;
587 qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16;
588#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
589 qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32;
590 qTransformFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_transform_image_argb32_on_argb32;
591 qTransformFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_transform_image_rgb32_on_rgb32;
592 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