1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
694 */ |
694 */ |
695 |
695 |
696 /*! |
696 /*! |
697 \enum QImage::Format |
697 \enum QImage::Format |
698 |
698 |
699 The following image formats are available in all versions of Qt: |
699 The following image formats are available in Qt. Values greater |
|
700 than QImage::Format_RGB16 were added in Qt 4.4. See the notes |
|
701 after the table. |
700 |
702 |
701 \value Format_Invalid The image is invalid. |
703 \value Format_Invalid The image is invalid. |
702 \value Format_Mono The image is stored using 1-bit per pixel. Bytes are |
704 \value Format_Mono The image is stored using 1-bit per pixel. Bytes are |
703 packed with the most significant bit (MSB) first. |
705 packed with the most significant bit (MSB) first. |
704 \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are |
706 \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are |
705 packed with the less significant bit (LSB) first. |
707 packed with the less significant bit (LSB) first. |
706 |
708 |
707 \value Format_Indexed8 The image is stored using 8-bit indexes |
709 \value Format_Indexed8 The image is stored using 8-bit indexes |
708 into a colormap. \warning Drawing into a |
710 into a colormap. |
709 QImage with Indexed8 format is not |
|
710 supported. |
|
711 |
711 |
712 \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). |
712 \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). |
713 |
713 |
714 \value Format_ARGB32 The image is stored using a 32-bit ARGB |
714 \value Format_ARGB32 The image is stored using a 32-bit ARGB |
715 format (0xAARRGGBB). \warning Do not |
715 format (0xAARRGGBB). |
716 render into ARGB32 images using |
|
717 QPainter. Format_ARGB32_Premultiplied is |
|
718 significantly faster. |
|
719 |
716 |
720 \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit |
717 \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit |
721 ARGB format (0xAARRGGBB), i.e. the red, |
718 ARGB format (0xAARRGGBB), i.e. the red, |
722 green, and blue channels are multiplied |
719 green, and blue channels are multiplied |
723 by the alpha component divided by 255. (If RR, GG, or BB |
720 by the alpha component divided by 255. (If RR, GG, or BB |
741 \value Format_RGB888 The image is stored using a 24-bit RGB format (8-8-8). |
738 \value Format_RGB888 The image is stored using a 24-bit RGB format (8-8-8). |
742 \value Format_RGB444 The image is stored using a 16-bit RGB format (4-4-4). |
739 \value Format_RGB444 The image is stored using a 16-bit RGB format (4-4-4). |
743 The unused bits are always zero. |
740 The unused bits are always zero. |
744 \value Format_ARGB4444_Premultiplied The image is stored using a |
741 \value Format_ARGB4444_Premultiplied The image is stored using a |
745 premultiplied 16-bit ARGB format (4-4-4-4). |
742 premultiplied 16-bit ARGB format (4-4-4-4). |
|
743 |
|
744 \note Drawing into a QImage with QImage::Format_Indexed8 is not |
|
745 supported. |
|
746 |
|
747 \note Do not render into ARGB32 images using QPainter. Using |
|
748 QImage::Format_ARGB32_Premultiplied is significantly faster. |
746 |
749 |
747 \sa format(), convertToFormat() |
750 \sa format(), convertToFormat() |
748 */ |
751 */ |
749 |
752 |
750 /***************************************************************************** |
753 /***************************************************************************** |
3987 return QImage(); |
3990 return QImage(); |
3988 |
3991 |
3989 QSize newSize = size(); |
3992 QSize newSize = size(); |
3990 newSize.scale(s, aspectMode); |
3993 newSize.scale(s, aspectMode); |
3991 if (newSize == size()) |
3994 if (newSize == size()) |
3992 return copy(); |
3995 return *this; |
3993 |
3996 |
3994 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); |
3997 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); |
3995 QImage img = transformed(wm, mode); |
3998 QImage img = transformed(wm, mode); |
3996 return img; |
3999 return img; |
3997 } |
4000 } |