41 #include <private/qimagescale_p.h> 42 #include <private/qdrawhelper_p.h> 54 int dxx,
int dyy,
int dx,
int dy,
int dw,
55 int dh,
int dow,
int sow);
58 int dxx,
int dyy,
int dx,
int dy,
int dw,
59 int dh,
int dow,
int sow);
62 int dxx,
int dyy,
int dx,
int dy,
int dw,
63 int dh,
int dow,
int sow);
129 int dw,
int dh,
char aa);
140 #define A_VAL(p) (qAlpha(*p)) 141 #define R_VAL(p) (qRed(*p)) 142 #define G_VAL(p) (qGreen(*p)) 143 #define B_VAL(p) (qBlue(*p)) 145 #define INV_XAP (256 - xapoints[x]) 146 #define XAP (xapoints[x]) 147 #define INV_YAP (256 - yapoints[dyy + y]) 148 #define YAP (yapoints[dyy + y]) 151 int sw,
int sh,
int dh)
155 int val, inc, rv = 0;
161 p =
new unsigned int* [dh+1];
163 int up =
qAbs(dh) >= sh;
164 val = up ? 0x8000 * sh / dh - 0x8000 : 0;
165 inc = (sh << 16) / dh;
166 for(i = 0; i < dh; i++){
167 p[j++] = src +
qMax(0, val >> 16) * sw;
171 for(i = dh / 2; --i >= 0; ){
172 unsigned int *tmp = p[i];
173 p[i] = p[dh - i - 1];
183 int val, inc, rv = 0;
191 int up =
qAbs(dw) >= sw;
192 val = up ? 0x8000 * sw / dw - 0x8000 : 0;
193 inc = (sw << 16) / dw;
194 for(i = 0; i < dw; i++){
195 p[j++] =
qMax(0, val >> 16);
200 for(i = dw / 2; --i >= 0; ){
202 p[i] = p[dw - i - 1];
211 int *p, i, j = 0, rv = 0;
223 val = 0x8000 * s / d - 0x8000;
225 for(i = 0; i <
d; i++){
229 else if (pos >= (s - 1))
232 p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
238 int val, inc, ap, Cp;
241 Cp = ((d << 14) / s) + 1;
242 for(i = 0; i <
d; i++){
243 ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
244 p[j] = ap | (Cp << 16);
251 for(i = d / 2; --i >= 0; ){
274 int dw,
int dh,
char aa)
287 isi->xup_yup = (
qAbs(dw) >= sw) + ((
qAbs(dh) >= sh) << 1);
311 int dxx,
int dyy,
int dx,
int dy,
int dw,
312 int dh,
int dow,
int sow)
314 unsigned int *sptr, *dptr;
325 for(y = 0; y < dh; y++){
327 dptr = dest + dx + ((y + dy) * dow);
328 sptr = ypoints[dyy + y];
330 for(x = dxx; x <
end; x++){
336 pix = ypoints[dyy + y] + xpoints[x];
357 g = ((gg *
YAP) + (g * INV_YAP)) >> 16;
358 b = ((bb *
YAP) + (b * INV_YAP)) >> 16;
359 a = ((aa *
YAP) + (a * INV_YAP)) >> 16;
360 *dptr++ =
qRgba(r, g, b, a);
363 pix = ypoints[dyy + y] + xpoints[x];
377 *dptr++ =
qRgba(r, g, b, a);
382 for(x = dxx; x <
end; x++){
387 pix = ypoints[dyy + y] + xpoints[x];
401 *dptr++ =
qRgba(r, g, b, a);
404 *dptr++ = sptr[xpoints[x] ];
414 int r, g, b,
a, rr, gg, bb, aa;
418 for(y = 0; y < dh; y++){
422 dptr = dest + dx + ((y + dy) * dow);
423 for(x = dxx; x <
end; x++){
424 pix = ypoints[dyy + y] + xpoints[x];
425 r =
R_VAL(pix) * yap;
426 g =
G_VAL(pix) * yap;
427 b =
B_VAL(pix) * yap;
428 a =
A_VAL(pix) * yap;
429 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
431 r +=
R_VAL(pix) * Cy;
432 g +=
G_VAL(pix) * Cy;
433 b +=
B_VAL(pix) * Cy;
434 a +=
A_VAL(pix) * Cy;
444 pix = ypoints[dyy + y] + xpoints[x] + 1;
445 rr =
R_VAL(pix) * yap;
446 gg =
G_VAL(pix) * yap;
447 bb =
B_VAL(pix) * yap;
448 aa =
A_VAL(pix) * yap;
449 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
451 rr +=
R_VAL(pix) * Cy;
452 gg +=
G_VAL(pix) * Cy;
453 bb +=
B_VAL(pix) * Cy;
454 aa +=
A_VAL(pix) * Cy;
458 rr +=
R_VAL(pix) * j;
459 gg +=
G_VAL(pix) * j;
460 bb +=
B_VAL(pix) * j;
461 aa +=
A_VAL(pix) * j;
467 r = (r + ((rr *
XAP))) >> 12;
468 g = (g + ((gg *
XAP))) >> 12;
469 b = (b + ((bb *
XAP))) >> 12;
470 a = (a + ((aa *
XAP))) >> 12;
478 *dptr =
qRgba(r >> 10, g >> 10, b >> 10, a >> 10);
488 int r, g, b,
a, rr, gg, bb, aa;
492 for(y = 0; y < dh; y++){
493 dptr = dest + dx + ((y + dy) * dow);
494 for(x = dxx; x <
end; x++){
498 pix = ypoints[dyy + y] + xpoints[x];
499 r =
R_VAL(pix) * xap;
500 g =
G_VAL(pix) * xap;
501 b =
B_VAL(pix) * xap;
502 a =
A_VAL(pix) * xap;
503 for(j = (1 << 14) - xap; j > Cx; j -= Cx){
505 r +=
R_VAL(pix) * Cx;
506 g +=
G_VAL(pix) * Cx;
507 b +=
B_VAL(pix) * Cx;
508 a +=
A_VAL(pix) * Cx;
518 pix = ypoints[dyy + y] + xpoints[x] + sow;
519 rr =
R_VAL(pix) * xap;
520 gg =
G_VAL(pix) * xap;
521 bb =
B_VAL(pix) * xap;
522 aa =
A_VAL(pix) * xap;
523 for(j = (1 << 14) - xap; j > Cx; j -= Cx){
525 rr +=
R_VAL(pix) * Cx;
526 gg +=
G_VAL(pix) * Cx;
527 bb +=
B_VAL(pix) * Cx;
528 aa +=
A_VAL(pix) * Cx;
532 rr +=
R_VAL(pix) * j;
533 gg +=
G_VAL(pix) * j;
534 bb +=
B_VAL(pix) * j;
535 aa +=
A_VAL(pix) * j;
541 r = (r + ((rr *
YAP))) >> 12;
542 g = (g + ((gg *
YAP))) >> 12;
543 b = (b + ((bb *
YAP))) >> 12;
544 a = (a + ((aa *
YAP))) >> 12;
552 *dptr =
qRgba(r >> 10, g >> 10, b >> 10, a >> 10);
566 int a, r, g, b, ax, rx, gx, bx;
569 for(y = 0; y < dh; y++){
573 dptr = dest + dx + ((y + dy) * dow);
574 for(x = dxx; x <
end; x++){
578 sptr = ypoints[dyy + y] + xpoints[x];
581 rx =
R_VAL(pix) * xap;
582 gx =
G_VAL(pix) * xap;
583 bx =
B_VAL(pix) * xap;
584 ax =
A_VAL(pix) * xap;
587 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
588 rx +=
R_VAL(pix) * Cx;
589 gx +=
G_VAL(pix) * Cx;
590 bx +=
B_VAL(pix) * Cx;
591 ax +=
A_VAL(pix) * Cx;
595 rx +=
R_VAL(pix) * i;
596 gx +=
G_VAL(pix) * i;
597 bx +=
B_VAL(pix) * i;
598 ax +=
A_VAL(pix) * i;
606 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
609 rx =
R_VAL(pix) * xap;
610 gx =
G_VAL(pix) * xap;
611 bx =
B_VAL(pix) * xap;
612 ax =
A_VAL(pix) * xap;
614 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
615 rx +=
R_VAL(pix) * Cx;
616 gx +=
G_VAL(pix) * Cx;
617 bx +=
B_VAL(pix) * Cx;
618 ax +=
A_VAL(pix) * Cx;
622 rx +=
R_VAL(pix) * i;
623 gx +=
G_VAL(pix) * i;
624 bx +=
B_VAL(pix) * i;
625 ax +=
A_VAL(pix) * i;
636 rx =
R_VAL(pix) * xap;
637 gx =
G_VAL(pix) * xap;
638 bx =
B_VAL(pix) * xap;
639 ax =
A_VAL(pix) * xap;
641 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
642 rx +=
R_VAL(pix) * Cx;
643 gx +=
G_VAL(pix) * Cx;
644 bx +=
B_VAL(pix) * Cx;
645 ax +=
A_VAL(pix) * Cx;
649 rx +=
R_VAL(pix) * i;
650 gx +=
G_VAL(pix) * i;
651 bx +=
B_VAL(pix) * i;
652 ax +=
A_VAL(pix) * i;
661 *dptr =
qRgba(r >> 23, g >> 23, b >> 23, a >> 23);
670 int dxx,
int dyy,
int dx,
int dy,
int dw,
671 int dh,
int dow,
int sow)
673 unsigned int *sptr, *dptr;
684 for(y = 0; y < dh; y++){
686 dptr = dest + dx + ((y + dy) * dow);
687 sptr = ypoints[dyy + y];
689 for(x = dxx; x <
end; x++){
690 int r = 0, g = 0, b = 0;
691 int rr = 0, gg = 0, bb = 0;
695 pix = ypoints[dyy + y] + xpoints[x];
712 g = ((gg *
YAP) + (g * INV_YAP)) >> 16;
713 b = ((bb *
YAP) + (b * INV_YAP)) >> 16;
714 *dptr++ =
qRgba(r, g, b, 0xff);
717 pix = ypoints[dyy + y] + xpoints[x];
728 *dptr++ =
qRgba(r, g, b, 0xff);
733 for(x = dxx; x <
end; x++){
734 int r = 0, g = 0, b = 0;
738 pix = ypoints[dyy + y] + xpoints[x];
749 *dptr++ =
qRgba(r, g, b, 0xff);
752 *dptr++ = sptr[xpoints[x] ];
762 int r, g, b, rr, gg, bb;
766 for(y = 0; y < dh; y++){
770 dptr = dest + dx + ((y + dy) * dow);
771 for(x = dxx; x <
end; x++){
772 pix = ypoints[dyy + y] + xpoints[x];
773 r =
R_VAL(pix) * yap;
774 g =
G_VAL(pix) * yap;
775 b =
B_VAL(pix) * yap;
777 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
778 r +=
R_VAL(pix) * Cy;
779 g +=
G_VAL(pix) * Cy;
780 b +=
B_VAL(pix) * Cy;
789 pix = ypoints[dyy + y] + xpoints[x] + 1;
790 rr =
R_VAL(pix) * yap;
791 gg =
G_VAL(pix) * yap;
792 bb =
B_VAL(pix) * yap;
794 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
795 rr +=
R_VAL(pix) * Cy;
796 gg +=
G_VAL(pix) * Cy;
797 bb +=
B_VAL(pix) * Cy;
801 rr +=
R_VAL(pix) * j;
802 gg +=
G_VAL(pix) * j;
803 bb +=
B_VAL(pix) * j;
808 r = (r + ((rr *
XAP))) >> 12;
809 g = (g + ((gg *
XAP))) >> 12;
810 b = (b + ((bb *
XAP))) >> 12;
817 *dptr =
qRgba(r >> 10, g >> 10, b >> 10, 0xff);
827 int r, g, b, rr, gg, bb;
831 for(y = 0; y < dh; y++){
832 dptr = dest + dx + ((y + dy) * dow);
833 for(x = dxx; x <
end; x++){
837 pix = ypoints[dyy + y] + xpoints[x];
838 r =
R_VAL(pix) * xap;
839 g =
G_VAL(pix) * xap;
840 b =
B_VAL(pix) * xap;
842 for(j = (1 << 14) - xap; j > Cx; j -= Cx){
843 r +=
R_VAL(pix) * Cx;
844 g +=
G_VAL(pix) * Cx;
845 b +=
B_VAL(pix) * Cx;
854 pix = ypoints[dyy + y] + xpoints[x] + sow;
855 rr =
R_VAL(pix) * xap;
856 gg =
G_VAL(pix) * xap;
857 bb =
B_VAL(pix) * xap;
859 for(j = (1 << 14) - xap; j > Cx; j -= Cx){
860 rr +=
R_VAL(pix) * Cx;
861 gg +=
G_VAL(pix) * Cx;
862 bb +=
B_VAL(pix) * Cx;
866 rr +=
R_VAL(pix) * j;
867 gg +=
G_VAL(pix) * j;
868 bb +=
B_VAL(pix) * j;
873 r = (r + ((rr *
YAP))) >> 12;
874 g = (g + ((gg *
YAP))) >> 12;
875 b = (b + ((bb *
YAP))) >> 12;
882 *dptr =
qRgba(r >> 10, g >> 10, b >> 10, 0xff);
893 int r, g, b, rx, gx, bx;
896 for(y = 0; y < dh; y++){
900 dptr = dest + dx + ((y + dy) * dow);
901 for(x = dxx; x <
end; x++){
905 sptr = ypoints[dyy + y] + xpoints[x];
908 rx =
R_VAL(pix) * xap;
909 gx =
G_VAL(pix) * xap;
910 bx =
B_VAL(pix) * xap;
912 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
913 rx +=
R_VAL(pix) * Cx;
914 gx +=
G_VAL(pix) * Cx;
915 bx +=
B_VAL(pix) * Cx;
919 rx +=
R_VAL(pix) * i;
920 gx +=
G_VAL(pix) * i;
921 bx +=
B_VAL(pix) * i;
928 for(j = (1 << 14) - yap; j > Cy; j -= Cy){
931 rx =
R_VAL(pix) * xap;
932 gx =
G_VAL(pix) * xap;
933 bx =
B_VAL(pix) * xap;
935 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
936 rx +=
R_VAL(pix) * Cx;
937 gx +=
G_VAL(pix) * Cx;
938 bx +=
B_VAL(pix) * Cx;
942 rx +=
R_VAL(pix) * i;
943 gx +=
G_VAL(pix) * i;
944 bx +=
B_VAL(pix) * i;
954 rx =
R_VAL(pix) * xap;
955 gx =
G_VAL(pix) * xap;
956 bx =
B_VAL(pix) * xap;
958 for(i = (1 << 14) - xap; i > Cx; i -= Cx){
959 rx +=
R_VAL(pix) * Cx;
960 gx +=
G_VAL(pix) * Cx;
961 bx +=
B_VAL(pix) * Cx;
965 rx +=
R_VAL(pix) * i;
966 gx +=
G_VAL(pix) * i;
967 bx +=
B_VAL(pix) * i;
975 *dptr =
qRgb(r >> 23, g >> 23, b >> 23);
983 static void qt_qimageScaleAARGBASetup(
QImageScaleInfo *isi,
unsigned int *dest,
984 int dxx,
int dyy,
int dx,
int dy,
int dw,
985 int dh,
int dow,
int sow)
991 static void qt_qimageScaleAARGBSetup(
QImageScaleInfo *isi,
unsigned int *dest,
992 int dxx,
int dyy,
int dx,
int dy,
int dw,
993 int dh,
int dow,
int sow)
1003 if (src.
isNull() || dw <= 0 || dh <= 0)
1006 int w = src.
width();
1015 qWarning(
"QImage: out of memory, returning null");
QImageScaleInfo * qimageFreeScaleInfo(QImageScaleInfo *isi)
#define QT_END_NAMESPACE
This macro expands to.
qt_qimageScaleFunc qt_qimageScaleArgb
bool isNull() const
Returns true if it is a null image, otherwise returns false.
void qInitDrawhelperAsm()
int bytesPerLine() const
Returns the number of bytes per image scanline.
long ASN1_INTEGER_get ASN1_INTEGER * a
qt_qimageScaleFunc qt_qimageScaleRgb
int * qimageCalcXPoints(int sw, int dw)
Q_DECL_CONSTEXPR T qAbs(const T &t)
Format format() const
Returns the format of the image.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
int width() const
Returns the width of the image.
int * qimageCalcApoints(int s, int d, int up)
void(* qt_qimageScaleFunc)(QImageScale::QImageScaleInfo *isi, unsigned int *dest, int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
static void qt_qimageScaleAARGB(QImageScale::QImageScaleInfo *isi, unsigned int *dest, int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
unsigned int ** qimageCalcYPoints(unsigned int *src, int sw, int sh, int dh)
int height() const
Returns the height of the image.
QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
QImageScaleInfo * qimageCalcScaleInfo(const QImage &img, int sw, int sh, int dw, int dh, char aa)
static void qt_qimageScaleAARGBA(QImageScale::QImageScaleInfo *isi, unsigned int *dest, int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
static const KeyPair *const end
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.