Changeset 561 for trunk/src/gui/image/qimage.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/image/qimage.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 #include "qstringlist.h" 51 51 #include "qvariant.h" 52 52 53 #include <ctype.h> 53 54 #include <stdlib.h> … … 61 62 #include <qhash.h> 62 63 63 #ifdef QT_RASTER_IMAGEENGINE64 64 #include <private/qpaintengine_raster_p.h> 65 #else66 #include <qpaintengine.h>67 #endif68 65 69 66 #include <private/qimage_p.h> … … 106 103 } 107 104 108 109 // ### Qt 5: remove110 typedef void (*_qt_image_cleanup_hook)(int);111 Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0;112 113 // ### Qt 5: rename114 typedef void (*_qt_image_cleanup_hook_64)(qint64);115 Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0;116 105 117 106 static QImage rotated90(const QImage &src); … … 186 175 } 187 176 177 178 179 180 181 182 183 188 184 QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors) 189 185 { … … 224 220 return 0; 225 221 226 Q ImageData *d = new QImageData;222 Q; 227 223 d->colortable.resize(numColors); 228 224 if (depth == 1) { … … 247 243 248 244 if (!d->data) { 249 delete d;250 245 return 0; 251 246 } 252 247 253 248 d->ref.ref(); 254 return d ;249 return d; 255 250 256 251 } … … 258 253 QImageData::~QImageData() 259 254 { 260 if (is_cached && qt_image_cleanup_hook_64)261 qt_image_cleanup_hook_64((((qint64) ser_no) << 32) | ((qint64) detach_no));255 if (is_cached) 256 ((((qint64) ser_no) << 32) | ((qint64) detach_no)); 262 257 delete paintEngine; 263 258 if (data && own_data) … … 345 340 \class QImage 346 341 347 \ingroup multimedia342 \ingroup 348 343 \ingroup shared 349 \mainclass 344 350 345 \reentrant 351 346 … … 382 377 \note If you would like to load QImage objects in a static build of Qt, 383 378 refer to the \l{How To Create Qt Plugins#Static Plugins}{Plugin HowTo}. 379 380 381 384 382 385 383 \tableofcontents … … 452 450 as a QRgb value indepedent of the image's format. 453 451 454 In case of monochrome and 8-bit images, the numColors() and452 In case of monochrome and 8-bit images, the () and 455 453 colorTable() functions provide information about the color 456 454 components used to store the image data: The colorTable() function … … 487 485 \l {QImage#Image Formats}{Image Formats} section). 488 486 489 The format(), bytesPerLine(), and numBytes() functions provide487 The format(), bytesPerLine(), and () functions provide 490 488 low-level information about the data stored in the image. 491 489 … … 549 547 size of the integer varies depending on the format. QImage 550 548 supports several image formats described by the \l Format 551 enum. The monochrome (1-bit), 8-bit and 32-bit images are 552 available in all versions of Qt. In addition Qt for Embedded Linux 553 also supports 2-bit, 4-bit, and 16-bit images. For more information 554 about the Qt Extended specific formats, see the documentation of the \l 555 Format enum. 549 enum. 556 550 557 551 Monochrome images are stored using 1-bit indexes into a color table … … 591 585 The mirrored() function returns a mirror of the image in the 592 586 desired direction, the scaled() returns a copy of the image scaled 593 to a rectangle of the desired measures, the rgbSwapped() function 594 constructs a BGR image from a RGB image, and the alphaChannel() 595 function constructs an image from this image's alpha channel. 587 to a rectangle of the desired measures, and the rgbSwapped() function 588 constructs a BGR image from a RGB image. 596 589 597 590 The scaledToWidth() and scaledToHeight() functions return scaled … … 612 605 \table 613 606 \header \o Function \o Description 614 \row615 \o setAlphaChannel()616 \o Sets the alpha channel of the image.617 607 \row 618 608 \o setDotsPerMeterX() … … 634 624 monochrome and 8-bit formats. 635 625 \row 636 \o set NumColors()626 \o set() 637 627 \o Resizes the color table. Only monochrome and 8-bit formats. 638 628 … … 707 697 \enum QImage::Format 708 698 709 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. 710 702 711 703 \value Format_Invalid The image is invalid. … … 714 706 \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are 715 707 packed with the less significant bit (LSB) first. 716 \value Format_Indexed8 The image is stored using 8-bit indexes into a colormap. 708 709 \value Format_Indexed8 The image is stored using 8-bit indexes 710 into a colormap. 711 717 712 \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). 718 \value Format_ARGB32 The image is stored using a 32-bit ARGB format (0xAARRGGBB). 713 714 \value Format_ARGB32 The image is stored using a 32-bit ARGB 715 format (0xAARRGGBB). 716 719 717 \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit 720 718 ARGB format (0xAARRGGBB), i.e. the red, … … 725 723 using alpha blending) are faster using premultiplied ARGB32 726 724 than with plain ARGB32. 725 727 726 \value Format_RGB16 The image is stored using a 16-bit RGB format (5-6-5). 727 728 728 \value Format_ARGB8565_Premultiplied The image is stored using a 729 729 premultiplied 24-bit ARGB format (8-5-6-5). … … 741 741 \value Format_ARGB4444_Premultiplied The image is stored using a 742 742 premultiplied 16-bit ARGB format (4-4-4-4). 743 744 745 746 747 748 743 749 744 750 \sa format(), convertToFormat() … … 904 910 If \a format is an indexed color format, the image color table is 905 911 initially empty and must be sufficiently expanded with 906 set NumColors() or setColorTable() before the image is used.912 set() or setColorTable() before the image is used. 907 913 */ 908 914 QImage::QImage(uchar* data, int width, int height, Format format) … … 926 932 If \a format is an indexed color format, the image color table is 927 933 initially empty and must be sufficiently expanded with 928 set NumColors() or setColorTable() before the image is used.934 set() or setColorTable() before the image is used. 929 935 930 936 Unlike the similar QImage constructor that takes a non-const data buffer, … … 952 958 If \a format is an indexed color format, the image color table is 953 959 initially empty and must be sufficiently expanded with 954 set NumColors() or setColorTable() before the image is used.960 set() or setColorTable() before the image is used. 955 961 */ 956 962 QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format) … … 972 978 If \a format is an indexed color format, the image color table is 973 979 initially empty and must be sufficiently expanded with 974 set NumColors() or setColorTable() before the image is used.980 set() or setColorTable() before the image is used. 975 981 976 982 Unlike the similar QImage constructor that takes a non-const data buffer, … … 1124 1130 Use the constructor that accepts a width, a height and a format 1125 1131 (i.e. specifying the depth and bit order), in combination with the 1126 set NumColors() function, instead.1132 set() function, instead. 1127 1133 1128 1134 \oldcode … … 1133 1139 // For 8 bit images the default number of colors is 256. If 1134 1140 // another number of colors is required it can be specified 1135 // using the set NumColors() function.1136 image.set NumColors(numColors);1141 // using the set() function. 1142 image.set(numColors); 1137 1143 \endcode 1138 1144 */ 1139 1145 1140 QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)1146 QImage::QImage(int w, int h, int depth, int , Endian bitOrder) 1141 1147 : QPaintDevice() 1142 1148 { 1143 d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors);1149 d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), ); 1144 1150 } 1145 1151 … … 1150 1156 Use the constructor that accepts a size and a format 1151 1157 (i.e. specifying the depth and bit order), in combination with the 1152 set NumColors() function, instead.1158 set() function, instead. 1153 1159 1154 1160 \oldcode … … 1161 1167 // For 8 bit images the default number of colors is 256. If 1162 1168 // another number of colors is required it can be specified 1163 // using the set NumColors() function.1164 image.set NumColors(numColors);1169 // using the set() function. 1170 image.set(numColors); 1165 1171 \endcode 1166 1172 */ … … 1230 1236 d->colortable[i] = colortable[i]; 1231 1237 } else if (numColors) { 1232 set NumColors(numColors);1238 set(numColors); 1233 1239 } 1234 1240 } … … 1281 1287 d->colortable[i] = colortable[i]; 1282 1288 } else if (numColors) { 1283 set NumColors(numColors);1289 set(numColors); 1284 1290 } 1285 1291 } … … 1347 1353 { 1348 1354 if (d) { 1349 if (d->is_cached && qt_image_cleanup_hook_64 &&d->ref == 1)1350 qt_image_cleanup_hook_64(cacheKey());1355 if (d->is_cached && d->ref == 1) 1356 (cacheKey()); 1351 1357 1352 1358 if (d->ref != 1 || d->ro_data) … … 1590 1596 1591 1597 /*! 1598 1592 1599 \fn int QImage::numColors() const 1593 1600 1594 1601 Returns the size of the color table for the image. 1595 1602 1596 Notice that numColors() returns 0 for 32-bpp images because these 1603 \sa setColorCount() 1604 */ 1605 int QImage::numColors() const 1606 { 1607 return d ? d->colortable.size() : 0; 1608 } 1609 1610 /*! 1611 \since 4.6 1612 \fn int QImage::colorCount() const 1613 1614 Returns the size of the color table for the image. 1615 1616 Notice that colorCount() returns 0 for 32-bpp images because these 1597 1617 images do not use color tables, but instead encode pixel values as 1598 1618 ARGB quadruplets. 1599 1619 1600 \sa set NumColors(), {QImage#Image Information}{Image Information}1601 */ 1602 int QImage:: numColors() const1620 \sa set(), {QImage#Image Information}{Image Information} 1621 */ 1622 int QImage::() const 1603 1623 { 1604 1624 return d ? d->colortable.size() : 0; … … 1622 1642 Returns a pointer to the scanline pointer table. This is the 1623 1643 beginning of the data block for the image. 1644 1624 1645 1625 1646 Use the bits() or scanLine() function instead. … … 1637 1658 if (!d->jumptable) { 1638 1659 d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); 1660 1661 1639 1662 uchar *data = d->data; 1640 1663 int height = d->height; … … 1657 1680 if (!d->jumptable) { 1658 1681 d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *)); 1682 1683 1659 1684 uchar *data = d->data; 1660 1685 int height = d->height; … … 1692 1717 d->colortable = colors; 1693 1718 d->has_alpha_clut = false; 1694 for (int i = 0; i < d->colortable.size(); ++i) 1695 d->has_alpha_clut |= (qAlpha(d->colortable.at(i)) != 255); 1719 for (int i = 0; i < d->colortable.size(); ++i) { 1720 if (qAlpha(d->colortable.at(i)) != 255) { 1721 d->has_alpha_clut = true; 1722 break; 1723 } 1724 } 1696 1725 } 1697 1726 … … 1700 1729 or an empty list if the image does not have a color table 1701 1730 1702 \sa setColorTable(), numColors(), color()1731 \sa setColorTable(), (), color() 1703 1732 */ 1704 1733 QVector<QRgb> QImage::colorTable() const … … 1709 1738 1710 1739 /*! 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1711 1752 Returns the number of bytes occupied by the image data. 1712 1753 … … 1714 1755 Information} 1715 1756 */ 1716 int QImage:: numBytes() const1757 int QImage::() const 1717 1758 { 1718 1759 return d ? d->nbytes : 0; … … 1722 1763 Returns the number of bytes per image scanline. 1723 1764 1724 This is equivalent to numBytes()/ height().1765 This is equivalent to / height(). 1725 1766 1726 1767 \sa scanLine() … … 1745 1786 QRgb QImage::color(int i) const 1746 1787 { 1747 Q_ASSERT(i < numColors());1788 Q_ASSERT(i < ()); 1748 1789 return d ? d->colortable.at(i) : QRgb(uint(-1)); 1749 1790 } … … 1756 1797 1757 1798 If \a index is outside the current size of the color table, it is 1758 expanded with set NumColors().1759 1760 \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel1799 expanded with set(). 1800 1801 \sa color(), (), setColorTable(), {QImage#Pixel Manipulation}{Pixel 1761 1802 Manipulation} 1762 1803 */ … … 1776 1817 1777 1818 if (i >= d->colortable.size()) 1778 set NumColors(i+1);1819 set(i+1); 1779 1820 d->colortable[i] = c; 1780 1821 d->has_alpha_clut |= (qAlpha(c) != 255); … … 1833 1874 current return value. 1834 1875 1835 \sa scanLine(), numBytes()1876 \sa scanLine(), () 1836 1877 */ 1837 1878 uchar *QImage::bits() … … 2014 2055 2015 2056 /*! 2057 2016 2058 Resizes the color table to contain \a numColors entries. 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2017 2071 2018 2072 If the color table is expanded, all the extra colors will be set to … … 2023 2077 otherwise the results are undefined. 2024 2078 2025 \sa numColors(), colorTable(), setColor(), {QImage#Image2079 \sa (), colorTable(), setColor(), {QImage#Image 2026 2080 Transformations}{Image Transformations} 2027 2081 */ 2028 2082 2029 void QImage::set NumColors(int numColors)2083 void QImage::set) 2030 2084 { 2031 2085 if (!d) { 2032 qWarning("QImage::set NumColors: null image");2086 qWarning("QImage::set: null image"); 2033 2087 return; 2034 2088 } … … 2040 2094 return; 2041 2095 2042 if ( numColors== d->colortable.size())2096 if ( == d->colortable.size()) 2043 2097 return; 2044 if ( numColors<= 0) { // use no color table2098 if ( <= 0) { // use no color table 2045 2099 d->colortable = QVector<QRgb>(); 2046 2100 return; 2047 2101 } 2048 2102 int nc = d->colortable.size(); 2049 d->colortable.resize( numColors);2050 for (int i = nc; i < numColors; ++i)2103 d->colortable.resize(); 2104 for (int i = nc; i < ; ++i) 2051 2105 d->colortable[i] = 0; 2052 2053 2106 } 2054 2107 … … 2371 2424 switch (dithermode) { 2372 2425 case Diffuse: { 2373 int *line1 = new int[w]; 2374 int *line2 = new int[w]; 2426 QScopedArrayPointer<int> lineBuffer(new int[w * 2]); 2427 int *line1 = lineBuffer.data(); 2428 int *line2 = lineBuffer.data() + w; 2375 2429 int bmwidth = (w+7)/8; 2376 2430 … … 2452 2506 } 2453 2507 } 2454 delete [] line1;2455 delete [] line2;2456 2508 } break; 2457 2509 case Ordered: { … … 2594 2646 static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) 2595 2647 { 2596 QImageData *tmp = QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32); 2597 convert_ARGB_PM_to_ARGB(tmp, src, flags); 2598 dither_to_Mono(dst, tmp, flags, false); 2599 delete tmp; 2648 QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); 2649 convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); 2650 dither_to_Mono(dst, tmp.data(), flags, false); 2600 2651 } 2601 2652 … … 2746 2797 int* line2[3]; 2747 2798 int* pv[3]; 2748 line1[0] = new int[src->width]; 2749 line2[0] = new int[src->width]; 2750 line1[1] = new int[src->width]; 2751 line2[1] = new int[src->width]; 2752 line1[2] = new int[src->width]; 2753 line2[2] = new int[src->width]; 2754 pv[0] = new int[src->width]; 2755 pv[1] = new int[src->width]; 2756 pv[2] = new int[src->width]; 2799 QScopedArrayPointer<int> lineBuffer(new int[src->width * 9]); 2800 line1[0] = lineBuffer.data(); 2801 line2[0] = lineBuffer.data() + src->width; 2802 line1[1] = lineBuffer.data() + src->width * 2; 2803 line2[1] = lineBuffer.data() + src->width * 3; 2804 line1[2] = lineBuffer.data() + src->width * 4; 2805 line2[2] = lineBuffer.data() + src->width * 5; 2806 pv[0] = lineBuffer.data() + src->width * 6; 2807 pv[1] = lineBuffer.data() + src->width * 7; 2808 pv[2] = lineBuffer.data() + src->width * 8; 2757 2809 2758 2810 int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); … … 2817 2869 dest_data += dst->bytes_per_line; 2818 2870 } 2819 delete [] line1[0];2820 delete [] line2[0];2821 delete [] line1[1];2822 delete [] line2[1];2823 delete [] line1[2];2824 delete [] line2[2];2825 delete [] pv[0];2826 delete [] pv[1];2827 delete [] pv[2];2828 2871 } else { // OrderedDither 2829 2872 for (int y = 0; y < src->height; y++) { … … 2858 2901 Q_ASSERT(dst->colortable.size() > trans); 2859 2902 dst->colortable[trans] = 0; 2860 Q ImageData *mask = QImageData::create(QSize(src->width, src->height), QImage::Format_Mono);2861 dither_to_Mono(mask , src, flags, true);2903 Q); 2904 dither_to_Mono(mask, src, flags, true); 2862 2905 uchar *dst_data = dst->data; 2863 2906 const uchar *mask_data = mask->data; … … 2871 2914 } 2872 2915 dst->has_alpha_clut = true; 2873 delete mask;2874 2916 } 2875 2917 … … 2884 2926 static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) 2885 2927 { 2886 QImageData *tmp = QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32); 2887 convert_ARGB_PM_to_ARGB(tmp, src, flags); 2888 convert_RGB_to_Indexed8(dst, tmp, flags); 2889 delete tmp; 2928 QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); 2929 convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); 2930 convert_RGB_to_Indexed8(dst, tmp.data(), flags); 2890 2931 } 2891 2932 … … 2905 2946 2906 2947 QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); 2948 2949 2950 2951 2952 2953 2907 2954 2908 2955 int w = src->width; … … 3607 3654 3608 3655 If the \a position is not valid, the results are undefined. 3656 3657 3658 3609 3659 3610 3660 \sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel … … 3666 3716 3667 3717 If \a position is not a valid coordinate pair in the image, or if 3668 \a index_or_rgb >= numColors() in the case of monochrome and3718 \a index_or_rgb >= () in the case of monochrome and 3669 3719 8-bit images, the result is undefined. 3670 3720 … … 3827 3877 if (d->colortable.isEmpty()) 3828 3878 return true; 3829 for (int i = 0; i < numColors(); i++)3879 for (int i = 0; i < (); i++) 3830 3880 if (!qIsGray(d->colortable.at(i))) 3831 3881 return false; … … 3854 3904 return allGray(); 3855 3905 case 8: { 3856 for (int i = 0; i < numColors(); i++)3906 for (int i = 0; i < (); i++) 3857 3907 if (d->colortable.at(i) != qRgb(i,i,i)) 3858 3908 return false; … … 3945 3995 return copy(); 3946 3996 3947 QImage img; 3948 QTransform wm; 3949 wm.scale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); 3950 img = transformed(wm, mode); 3997 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); 3998 QImage img = transformed(wm, mode); 3951 3999 return img; 3952 4000 } … … 3975 4023 return QImage(); 3976 4024 3977 QTransform wm;3978 4025 qreal factor = (qreal) w / width(); 3979 wm.scale(factor, factor);4026 cale(factor, factor); 3980 4027 return transformed(wm, mode); 3981 4028 } … … 4004 4051 return QImage(); 4005 4052 4006 QTransform wm;4007 4053 qreal factor = (qreal) h / height(); 4008 wm.scale(factor, factor);4054 cale(factor, factor); 4009 4055 return transformed(wm, mode); 4010 4056 } … … 4079 4125 4080 4126 QImage mask(d->width, d->height, Format_MonoLSB); 4081 dither_to_Mono(mask.d, d, flags, true); 4127 if (!mask.isNull()) 4128 dither_to_Mono(mask.d, d, flags, true); 4082 4129 return mask; 4083 4130 } … … 4123 4170 int h = height(); 4124 4171 QImage m(w, h, Format_MonoLSB); 4125 m.set NumColors(2);4172 m.set(2); 4126 4173 m.setColor(0, QColor(Qt::color0).rgba()); 4127 4174 m.setColor(1, QColor(Qt::color1).rgba()); … … 4275 4322 // Create result image, copy colormap 4276 4323 QImage result(d->width, d->height, d->format); 4324 4325 4326 4327 4328 4277 4329 result.d->colortable = d->colortable; 4278 4330 result.d->has_alpha_clut = d->has_alpha_clut; … … 4625 4677 specified \a format. If \a format is not specified (which is the default), 4626 4678 the loader probes the file for a header to guess the file format. 4627 4628 If the loading of the image failed, this object is a null image. 4629 4630 \sa load(), save(), {QImage#Reading and Writing Image 4631 Files}{Reading and Writing Image Files} 4632 */ 4679 binary \a data. The loader attempts to read the image, either using the 4680 optional image \a format specified or by determining the image format from 4681 the data. 4682 4683 If \a format is not specified (which is the default), the loader probes the 4684 file for a header to determine the file format. If \a format is specified, 4685 it must be one of the values returned by QImageReader::supportedImageFormats(). 4686 4687 If the loading of the image fails, the image returned will be a null image. 4688 4689 \sa load(), save(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files} 4690 */ 4691 4633 4692 QImage QImage::fromData(const uchar *data, int size, const char *format) 4634 4693 { … … 4757 4816 return s; 4758 4817 } 4759 #endif 4818 #endif 4760 4819 4761 4820 … … 4847 4906 4848 4907 if (d->format != Format_RGB32) { 4849 if (d->colortable != i.d->colortable)4850 return false;4851 4908 if (d->format >= Format_ARGB32) { // all bits defined 4852 4909 const int n = d->width * d->depth / 8; … … 4861 4918 } 4862 4919 } else { 4863 int w = width(); 4864 int h = height(); 4920 const int w = width(); 4921 const int h = height(); 4922 const QVector<QRgb> &colortable = d->colortable; 4923 const QVector<QRgb> &icolortable = i.d->colortable; 4865 4924 for (int y=0; y<h; ++y) { 4866 4925 for (int x=0; x<w; ++x) { 4867 if ( pixelIndex(x, y) != i.pixelIndex(x, y))4926 if () 4868 4927 return false; 4869 4928 } … … 4994 5053 \fn void QImage::setOffset(const QPoint& offset) 4995 5054 4996 Sets the thenumber of pixels by which the image is intended to be5055 Sets the number of pixels by which the image is intended to be 4997 5056 offset by when positioning relative to other images, to \a offset. 4998 5057 … … 5252 5311 return 0; 5253 5312 5254 #ifdef QT_RASTER_IMAGEENGINE5255 5313 if (!d->paintEngine) { 5256 5314 d->paintEngine = new QRasterPaintEngine(const_cast<QImage *>(this)); 5257 5315 } 5258 #endif 5316 5259 5317 return d->paintEngine; 5260 5318 } … … 5262 5320 5263 5321 /*! 5264 \ reimp5322 \ 5265 5323 5266 5324 Returns the size for the specified \a metric on the device. … … 5580 5638 format if the function succeeds. 5581 5639 5582 Use one of the composition mods in QPainter::CompositionMode instead. 5640 Use one of the composition modes in QPainter::CompositionMode instead. 5641 5642 \warning This function is expensive. 5583 5643 5584 5644 \sa alphaChannel(), {QImage#Image Transformations}{Image … … 5656 5716 5657 5717 /*! 5718 5719 5658 5720 Returns the alpha channel of the image as a new grayscale QImage in which 5659 5721 each pixel's red, green, and blue values are given the alpha value of the … … 5664 5726 this function on QPixmaps. 5665 5727 5728 5729 5730 5731 5732 5666 5733 \sa setAlphaChannel(), hasAlphaChannel(), 5667 5734 {QPixmap#Pixmap Information}{Pixmap}, … … 5678 5745 5679 5746 QImage image(w, h, Format_Indexed8); 5680 image.set NumColors(256);5747 image.set(256); 5681 5748 5682 5749 // set up gray scale table. … … 5730 5797 channel, otherwise returns false. 5731 5798 5732 \sa alphaChannel(),{QImage#Image Information}{Image Information}5799 \sa {QImage#Image Information}{Image Information} 5733 5800 */ 5734 5801 bool QImage::hasAlphaChannel() const … … 5808 5875 static QImage rotated90(const QImage &image) { 5809 5876 QImage out(image.height(), image.width(), image.format()); 5810 if (image. numColors() > 0)5877 if (image.() > 0) 5811 5878 out.setColorTable(image.colorTable()); 5812 5879 int w = image.width(); … … 5847 5914 default: 5848 5915 for (int y=0; y<h; ++y) { 5849 if (image. numColors())5916 if (image.()) 5850 5917 for (int x=0; x<w; ++x) 5851 5918 out.setPixel(h-y-1, x, image.pixelIndex(x, y)); … … 5867 5934 static QImage rotated270(const QImage &image) { 5868 5935 QImage out(image.height(), image.width(), image.format()); 5869 if (image. numColors() > 0)5936 if (image.() > 0) 5870 5937 out.setColorTable(image.colorTable()); 5871 5938 int w = image.width(); … … 5906 5973 default: 5907 5974 for (int y=0; y<h; ++y) { 5908 if (image. numColors())5975 if (image.()) 5909 5976 for (int x=0; x<w; ++x) 5910 5977 out.setPixel(y, w-x-1, image.pixelIndex(x, y)); … … 6046 6113 // colors are left in the color table, so pick that one as transparent 6047 6114 dImage.d->colortable.append(0x0); 6048 memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage. numBytes());6115 memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.()); 6049 6116 } else { 6050 memset(dImage.bits(), 0, dImage. numBytes());6117 memset(dImage.bits(), 0, dImage.()); 6051 6118 } 6052 6119 break; … … 6055 6122 case 24: 6056 6123 case 32: 6057 memset(dImage.bits(), 0x00, dImage. numBytes());6124 memset(dImage.bits(), 0x00, dImage.()); 6058 6125 break; 6059 6126 }
Note:
See TracChangeset
for help on using the changeset viewer.