Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/image/qimage.cpp

    r2 r561  
    22**
    33** 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])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050#include "qstringlist.h"
    5151#include "qvariant.h"
     52
    5253#include <ctype.h>
    5354#include <stdlib.h>
     
    6162#include <qhash.h>
    6263
    63 #ifdef QT_RASTER_IMAGEENGINE
    6464#include <private/qpaintengine_raster_p.h>
    65 #else
    66 #include <qpaintengine.h>
    67 #endif
    6865
    6966#include <private/qimage_p.h>
     
    106103    }
    107104
    108 
    109 // ### Qt 5: remove
    110 typedef void (*_qt_image_cleanup_hook)(int);
    111 Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0;
    112 
    113 // ### Qt 5: rename
    114 typedef void (*_qt_image_cleanup_hook_64)(qint64);
    115 Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0;
    116105
    117106static QImage rotated90(const QImage &src);
     
    186175}
    187176
     177
     178
     179
     180
     181
     182
     183
    188184QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
    189185{
     
    224220        return 0;
    225221
    226     QImageData *d = new QImageData;
     222    Q;
    227223    d->colortable.resize(numColors);
    228224    if (depth == 1) {
     
    247243
    248244    if (!d->data) {
    249         delete d;
    250245        return 0;
    251246    }
    252247
    253248    d->ref.ref();
    254     return d;
     249    return d;
    255250
    256251}
     
    258253QImageData::~QImageData()
    259254{
    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));
    262257    delete paintEngine;
    263258    if (data && own_data)
     
    345340    \class QImage
    346341
    347     \ingroup multimedia
     342    \ingroup
    348343    \ingroup shared
    349     \mainclass
     344
    350345    \reentrant
    351346
     
    382377    \note If you would like to load QImage objects in a static build of Qt,
    383378    refer to the \l{How To Create Qt Plugins#Static Plugins}{Plugin HowTo}.
     379
     380
     381
    384382
    385383    \tableofcontents
     
    452450    as a QRgb value indepedent of the image's format.
    453451
    454     In case of monochrome and 8-bit images, the numColors() and
     452    In case of monochrome and 8-bit images, the () and
    455453    colorTable() functions provide information about the color
    456454    components used to store the image data: The colorTable() function
     
    487485    \l {QImage#Image Formats}{Image Formats} section).
    488486
    489     The format(), bytesPerLine(), and numBytes() functions provide
     487    The format(), bytesPerLine(), and () functions provide
    490488    low-level information about the data stored in the image.
    491489
     
    549547    size of the integer varies depending on the format. QImage
    550548    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.
    556550
    557551    Monochrome images are stored using 1-bit indexes into a color table
     
    591585    The mirrored() function returns a mirror of the image in the
    592586    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.
    596589
    597590    The scaledToWidth() and scaledToHeight() functions return scaled
     
    612605    \table
    613606    \header \o Function \o Description
    614     \row
    615     \o setAlphaChannel()
    616     \o Sets the alpha channel of the image.
    617607    \row
    618608    \o setDotsPerMeterX()
     
    634624    monochrome and 8-bit formats.
    635625    \row
    636     \o setNumColors()
     626    \o set()
    637627    \o Resizes the color table. Only monochrome and 8-bit formats.
    638628
     
    707697    \enum QImage::Format
    708698
    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.
    710702
    711703    \value Format_Invalid   The image is invalid.
     
    714706    \value Format_MonoLSB   The image is stored using 1-bit per pixel. Bytes are
    715707                            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
    717712    \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
    719717    \value Format_ARGB32_Premultiplied  The image is stored using a premultiplied 32-bit
    720718                            ARGB format (0xAARRGGBB), i.e. the red,
     
    725723                            using alpha blending) are faster using premultiplied ARGB32
    726724                            than with plain ARGB32.
     725
    727726    \value Format_RGB16     The image is stored using a 16-bit RGB format (5-6-5).
     727
    728728    \value Format_ARGB8565_Premultiplied  The image is stored using a
    729729                            premultiplied 24-bit ARGB format (8-5-6-5).
     
    741741    \value Format_ARGB4444_Premultiplied  The image is stored using a
    742742                            premultiplied 16-bit ARGB format (4-4-4-4).
     743
     744
     745
     746
     747
     748
    743749
    744750    \sa format(), convertToFormat()
     
    904910    If \a format is an indexed color format, the image color table is
    905911    initially empty and must be sufficiently expanded with
    906     setNumColors() or setColorTable() before the image is used.
     912    set() or setColorTable() before the image is used.
    907913*/
    908914QImage::QImage(uchar* data, int width, int height, Format format)
     
    926932    If \a format is an indexed color format, the image color table is
    927933    initially empty and must be sufficiently expanded with
    928     setNumColors() or setColorTable() before the image is used.
     934    set() or setColorTable() before the image is used.
    929935
    930936    Unlike the similar QImage constructor that takes a non-const data buffer,
     
    952958    If \a format is an indexed color format, the image color table is
    953959    initially empty and must be sufficiently expanded with
    954     setNumColors() or setColorTable() before the image is used.
     960    set() or setColorTable() before the image is used.
    955961*/
    956962QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format)
     
    972978    If \a format is an indexed color format, the image color table is
    973979    initially empty and must be sufficiently expanded with
    974     setNumColors() or setColorTable() before the image is used.
     980    set() or setColorTable() before the image is used.
    975981
    976982    Unlike the similar QImage constructor that takes a non-const data buffer,
     
    11241130    Use the constructor that accepts a width, a height and a format
    11251131    (i.e. specifying the depth and bit order), in combination with the
    1126     setNumColors() function, instead.
     1132    set() function, instead.
    11271133
    11281134    \oldcode
     
    11331139        // For 8 bit images the default number of colors is 256. If
    11341140        // another number of colors is required it can be specified
    1135         // using the setNumColors() function.
    1136         image.setNumColors(numColors);
     1141        // using the set() function.
     1142        image.set(numColors);
    11371143    \endcode
    11381144*/
    11391145
    1140 QImage::QImage(int w, int h, int depth, int numColors, Endian bitOrder)
     1146QImage::QImage(int w, int h, int depth, int , Endian bitOrder)
    11411147    : QPaintDevice()
    11421148{
    1143     d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), numColors);
     1149    d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), );
    11441150}
    11451151
     
    11501156    Use the constructor that accepts a size and a format
    11511157    (i.e. specifying the depth and bit order), in combination with the
    1152     setNumColors() function, instead.
     1158    set() function, instead.
    11531159
    11541160    \oldcode
     
    11611167        // For 8 bit images the default number of colors is 256. If
    11621168        // another number of colors is required it can be specified
    1163         // using the setNumColors() function.
    1164         image.setNumColors(numColors);
     1169        // using the set() function.
     1170        image.set(numColors);
    11651171    \endcode
    11661172*/
     
    12301236            d->colortable[i] = colortable[i];
    12311237    } else if (numColors) {
    1232         setNumColors(numColors);
     1238        set(numColors);
    12331239    }
    12341240}
     
    12811287            d->colortable[i] = colortable[i];
    12821288    } else if (numColors) {
    1283         setNumColors(numColors);
     1289        set(numColors);
    12841290    }
    12851291}
     
    13471353{
    13481354    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());
    13511357
    13521358        if (d->ref != 1 || d->ro_data)
     
    15901596
    15911597/*!
     1598
    15921599    \fn int QImage::numColors() const
    15931600
    15941601    Returns the size of the color table for the image.
    15951602
    1596     Notice that numColors() returns 0 for 32-bpp images because these
     1603    \sa setColorCount()
     1604*/
     1605int 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
    15971617    images do not use color tables, but instead encode pixel values as
    15981618    ARGB quadruplets.
    15991619
    1600     \sa setNumColors(), {QImage#Image Information}{Image Information}
    1601 */
    1602 int QImage::numColors() const
     1620    \sa set(), {QImage#Image Information}{Image Information}
     1621*/
     1622int QImage::() const
    16031623{
    16041624    return d ? d->colortable.size() : 0;
     
    16221642    Returns a pointer to the scanline pointer table. This is the
    16231643    beginning of the data block for the image.
     1644
    16241645
    16251646    Use the bits() or scanLine() function instead.
     
    16371658    if (!d->jumptable) {
    16381659        d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
     1660
     1661
    16391662        uchar *data = d->data;
    16401663        int height = d->height;
     
    16571680    if (!d->jumptable) {
    16581681        d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
     1682
     1683
    16591684        uchar *data = d->data;
    16601685        int height = d->height;
     
    16921717    d->colortable = colors;
    16931718    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    }
    16961725}
    16971726
     
    17001729    or an empty list if the image does not have a color table
    17011730
    1702     \sa setColorTable(), numColors(), color()
     1731    \sa setColorTable(), (), color()
    17031732*/
    17041733QVector<QRgb> QImage::colorTable() const
     
    17091738
    17101739/*!
     1740
     1741
     1742
     1743
     1744
     1745
     1746
     1747
     1748
     1749
     1750
     1751
    17111752    Returns the number of bytes occupied by the image data.
    17121753
     
    17141755    Information}
    17151756*/
    1716 int QImage::numBytes() const
     1757int QImage::() const
    17171758{
    17181759    return d ? d->nbytes : 0;
     
    17221763    Returns the number of bytes per image scanline.
    17231764
    1724     This is equivalent to numBytes()/ height().
     1765    This is equivalent to / height().
    17251766
    17261767    \sa scanLine()
     
    17451786QRgb QImage::color(int i) const
    17461787{
    1747     Q_ASSERT(i < numColors());
     1788    Q_ASSERT(i < ());
    17481789    return d ? d->colortable.at(i) : QRgb(uint(-1));
    17491790}
     
    17561797
    17571798    If \a index is outside the current size of the color table, it is
    1758     expanded with setNumColors().
    1759 
    1760     \sa color(), numColors(), setColorTable(), {QImage#Pixel Manipulation}{Pixel
     1799    expanded with set().
     1800
     1801    \sa color(), (), setColorTable(), {QImage#Pixel Manipulation}{Pixel
    17611802    Manipulation}
    17621803*/
     
    17761817
    17771818    if (i >= d->colortable.size())
    1778         setNumColors(i+1);
     1819        set(i+1);
    17791820    d->colortable[i] = c;
    17801821    d->has_alpha_clut |= (qAlpha(c) != 255);
     
    18331874    current return value.
    18341875
    1835     \sa scanLine(), numBytes()
     1876    \sa scanLine(), ()
    18361877*/
    18371878uchar *QImage::bits()
     
    20142055
    20152056/*!
     2057
    20162058    Resizes the color table to contain \a numColors entries.
     2059
     2060
     2061
     2062
     2063
     2064
     2065
     2066
     2067
     2068
     2069
     2070
    20172071
    20182072    If the color table is expanded, all the extra colors will be set to
     
    20232077    otherwise the results are undefined.
    20242078
    2025     \sa numColors(), colorTable(), setColor(), {QImage#Image
     2079    \sa (), colorTable(), setColor(), {QImage#Image
    20262080    Transformations}{Image Transformations}
    20272081*/
    20282082
    2029 void QImage::setNumColors(int numColors)
     2083void QImage::set)
    20302084{
    20312085    if (!d) {
    2032         qWarning("QImage::setNumColors: null image");
     2086        qWarning("QImage::set: null image");
    20332087        return;
    20342088    }
     
    20402094        return;
    20412095
    2042     if (numColors == d->colortable.size())
     2096    if ( == d->colortable.size())
    20432097        return;
    2044     if (numColors <= 0) {                        // use no color table
     2098    if ( <= 0) {                        // use no color table
    20452099        d->colortable = QVector<QRgb>();
    20462100        return;
    20472101    }
    20482102    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)
    20512105        d->colortable[i] = 0;
    2052 
    20532106}
    20542107
     
    23712424    switch (dithermode) {
    23722425    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;
    23752429        int bmwidth = (w+7)/8;
    23762430
     
    24522506            }
    24532507        }
    2454         delete [] line1;
    2455         delete [] line2;
    24562508    } break;
    24572509    case Ordered: {
     
    25942646static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
    25952647{
    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);
    26002651}
    26012652
     
    27462797            int* line2[3];
    27472798            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;
    27572809
    27582810            int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
     
    28172869                dest_data += dst->bytes_per_line;
    28182870            }
    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];
    28282871        } else { // OrderedDither
    28292872            for (int y = 0; y < src->height; y++) {
     
    28582901            Q_ASSERT(dst->colortable.size() > trans);
    28592902            dst->colortable[trans] = 0;
    2860             QImageData *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);
    28622905            uchar *dst_data = dst->data;
    28632906            const uchar *mask_data = mask->data;
     
    28712914            }
    28722915            dst->has_alpha_clut = true;
    2873             delete mask;
    28742916        }
    28752917
     
    28842926static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags)
    28852927{
    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);
    28902931}
    28912932
     
    29052946
    29062947    QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format);
     2948
     2949
     2950
     2951
     2952
     2953
    29072954
    29082955    int w = src->width;
     
    36073654
    36083655    If the \a position is not valid, the results are undefined.
     3656
     3657
     3658
    36093659
    36103660    \sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel
     
    36663716
    36673717    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 and
     3718    \a index_or_rgb >= () in the case of monochrome and
    36693719    8-bit images, the result is undefined.
    36703720
     
    38273877        if (d->colortable.isEmpty())
    38283878            return true;
    3829         for (int i = 0; i < numColors(); i++)
     3879        for (int i = 0; i < (); i++)
    38303880            if (!qIsGray(d->colortable.at(i)))
    38313881                return false;
     
    38543904        return allGray();
    38553905    case 8: {
    3856         for (int i = 0; i < numColors(); i++)
     3906        for (int i = 0; i < (); i++)
    38573907            if (d->colortable.at(i) != qRgb(i,i,i))
    38583908                return false;
     
    39453995        return copy();
    39463996
    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);
    39513999    return img;
    39524000}
     
    39754023        return QImage();
    39764024
    3977     QTransform wm;
    39784025    qreal factor = (qreal) w / width();
    3979     wm.scale(factor, factor);
     4026    cale(factor, factor);
    39804027    return transformed(wm, mode);
    39814028}
     
    40044051        return QImage();
    40054052
    4006     QTransform wm;
    40074053    qreal factor = (qreal) h / height();
    4008     wm.scale(factor, factor);
     4054    cale(factor, factor);
    40094055    return transformed(wm, mode);
    40104056}
     
    40794125
    40804126    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);
    40824129    return mask;
    40834130}
     
    41234170    int h = height();
    41244171    QImage m(w, h, Format_MonoLSB);
    4125     m.setNumColors(2);
     4172    m.set(2);
    41264173    m.setColor(0, QColor(Qt::color0).rgba());
    41274174    m.setColor(1, QColor(Qt::color1).rgba());
     
    42754322    // Create result image, copy colormap
    42764323    QImage result(d->width, d->height, d->format);
     4324
     4325
     4326
     4327
     4328
    42774329    result.d->colortable = d->colortable;
    42784330    result.d->has_alpha_clut = d->has_alpha_clut;
     
    46254677    specified \a format. If \a format is not specified (which is the default),
    46264678    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
    46334692QImage QImage::fromData(const uchar *data, int size, const char *format)
    46344693{
     
    47574816    return s;
    47584817}
    4759 #endif
     4818#endif
    47604819
    47614820
     
    48474906
    48484907    if (d->format != Format_RGB32) {
    4849         if (d->colortable != i.d->colortable)
    4850             return false;
    48514908        if (d->format >= Format_ARGB32) { // all bits defined
    48524909            const int n = d->width * d->depth / 8;
     
    48614918            }
    48624919        } 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;
    48654924            for (int y=0; y<h; ++y) {
    48664925                for (int x=0; x<w; ++x) {
    4867                     if (pixelIndex(x, y) != i.pixelIndex(x, y))
     4926                    if ()
    48684927                        return false;
    48694928                }
     
    49945053    \fn void QImage::setOffset(const QPoint& offset)
    49955054
    4996     Sets the the number of pixels by which the image is intended to be
     5055    Sets the number of pixels by which the image is intended to be
    49975056    offset by when positioning relative to other images, to \a offset.
    49985057
     
    52525311        return 0;
    52535312
    5254 #ifdef QT_RASTER_IMAGEENGINE
    52555313    if (!d->paintEngine) {
    52565314        d->paintEngine = new QRasterPaintEngine(const_cast<QImage *>(this));
    52575315    }
    5258 #endif
     5316
    52595317    return d->paintEngine;
    52605318}
     
    52625320
    52635321/*!
    5264     \reimp
     5322    \
    52655323
    52665324    Returns the size for the specified \a metric on the device.
     
    55805638    format if the function succeeds.
    55815639
    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.
    55835643
    55845644    \sa alphaChannel(), {QImage#Image Transformations}{Image
     
    56565716
    56575717/*!
     5718
     5719
    56585720    Returns the alpha channel of the image as a new grayscale QImage in which
    56595721    each pixel's red, green, and blue values are given the alpha value of the
     
    56645726    this function on QPixmaps.
    56655727
     5728
     5729
     5730
     5731
     5732
    56665733    \sa setAlphaChannel(), hasAlphaChannel(),
    56675734    {QPixmap#Pixmap Information}{Pixmap},
     
    56785745
    56795746    QImage image(w, h, Format_Indexed8);
    5680     image.setNumColors(256);
     5747    image.set(256);
    56815748
    56825749    // set up gray scale table.
     
    57305797    channel, otherwise returns false.
    57315798
    5732     \sa alphaChannel(), {QImage#Image Information}{Image Information}
     5799    \sa {QImage#Image Information}{Image Information}
    57335800*/
    57345801bool QImage::hasAlphaChannel() const
     
    58085875static QImage rotated90(const QImage &image) {
    58095876    QImage out(image.height(), image.width(), image.format());
    5810     if (image.numColors() > 0)
     5877    if (image.() > 0)
    58115878        out.setColorTable(image.colorTable());
    58125879    int w = image.width();
     
    58475914    default:
    58485915        for (int y=0; y<h; ++y) {
    5849             if (image.numColors())
     5916            if (image.())
    58505917                for (int x=0; x<w; ++x)
    58515918                    out.setPixel(h-y-1, x, image.pixelIndex(x, y));
     
    58675934static QImage rotated270(const QImage &image) {
    58685935    QImage out(image.height(), image.width(), image.format());
    5869     if (image.numColors() > 0)
     5936    if (image.() > 0)
    58705937        out.setColorTable(image.colorTable());
    58715938    int w = image.width();
     
    59065973    default:
    59075974        for (int y=0; y<h; ++y) {
    5908             if (image.numColors())
     5975            if (image.())
    59095976                for (int x=0; x<w; ++x)
    59105977                    out.setPixel(y, w-x-1, image.pixelIndex(x, y));
     
    60466113                // colors are left in the color table, so pick that one as transparent
    60476114                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.());
    60496116            } else {
    6050                 memset(dImage.bits(), 0, dImage.numBytes());
     6117                memset(dImage.bits(), 0, dImage.());
    60516118            }
    60526119            break;
     
    60556122        case 24:
    60566123        case 32:
    6057             memset(dImage.bits(), 0x00, dImage.numBytes());
     6124            memset(dImage.bits(), 0x00, dImage.());
    60586125            break;
    60596126    }
Note: See TracChangeset for help on using the changeset viewer.