src/gui/image/qpixmapfilter.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   775 #define AVG(a,b)  ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
   775 #define AVG(a,b)  ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
   776 #define AVG16(a,b)  ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
   776 #define AVG16(a,b)  ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
   777 
   777 
   778 Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
   778 Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
   779 {
   779 {
       
   780     if (source.width() < 2 || source.height() < 2)
       
   781         return QImage();
       
   782 
   780     QImage srcImage = source;
   783     QImage srcImage = source;
   781 
   784 
   782     if (source.format() == QImage::Format_Indexed8) {
   785     if (source.format() == QImage::Format_Indexed8) {
   783         // assumes grayscale
   786         // assumes grayscale
   784         QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
   787         QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
   867     {
   870     {
   868         blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
   871         blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
   869     }
   872     }
   870 
   873 
   871     qreal scale = 1;
   874     qreal scale = 1;
   872     if (radius >= 4) {
   875     if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
   873         blurImage = qt_halfScaled(blurImage);
   876         blurImage = qt_halfScaled(blurImage);
   874         scale = 2;
   877         scale = 2;
   875         radius *= qreal(0.5);
   878         radius *= qreal(0.5);
   876     }
   879     }
   877 
   880