Changeset 561 for trunk/src/gui/image/qpixmapdata.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/qpixmapdata.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 41 41 42 42 #include "qpixmapdata_p.h" 43 #include <QtCore/qbuffer.h> 43 44 #include <QtGui/qbitmap.h> 44 45 #include <QtGui/qimagereader.h> 46 #include <private/qgraphicssystem_p.h> 47 #include <private/qapplication_p.h> 45 48 46 49 QT_BEGIN_NAMESPACE … … 49 52 0x10, 0x20, 0x40, 0x80 }; 50 53 54 QPixmapData *QPixmapData::create(int w, int h, PixelType type) 55 { 56 QPixmapData *data; 57 QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); 58 if (gs) 59 data = gs->createPixmapData(static_cast<QPixmapData::PixelType>(type)); 60 else 61 data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type)); 62 data->resize(w, h); 63 return data; 64 } 65 66 51 67 QPixmapData::QPixmapData(PixelType pixelType, int objectId) 52 : ref(0), detach_no(0), type(pixelType), id(objectId), ser_no(0), is_cached(false) 53 { 54 68 : w(0), 69 h(0), 70 d(0), 71 is_null(true), 72 ref(0), 73 detach_no(0), 74 type(pixelType), 75 id(objectId), 76 ser_no(0), 77 is_cached(false) 78 { 55 79 } 56 80 … … 59 83 } 60 84 61 void QPixmapData::fromFile(const QString &fileName, const char *format, 85 QPixmapData *QPixmapData::createCompatiblePixmapData() const 86 { 87 QPixmapData *d; 88 QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); 89 if (gs) 90 d = gs->createPixmapData(pixelType()); 91 else 92 d = QGraphicsSystem::createDefaultPixmapData(pixelType()); 93 return d; 94 } 95 96 static QImage makeBitmapCompliantIfNeeded(QPixmapData *d, const QImage &image, Qt::ImageConversionFlags flags) 97 { 98 if (d->pixelType() == QPixmapData::BitmapType) { 99 QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); 100 101 // make sure image.color(0) == Qt::color0 (white) 102 // and image.color(1) == Qt::color1 (black) 103 const QRgb c0 = QColor(Qt::black).rgb(); 104 const QRgb c1 = QColor(Qt::white).rgb(); 105 if (img.color(0) == c0 && img.color(1) == c1) { 106 img.invertPixels(); 107 img.setColor(0, c1); 108 img.setColor(1, c0); 109 } 110 return img; 111 } 112 113 return image; 114 } 115 116 bool QPixmapData::fromFile(const QString &fileName, const char *format, 62 117 Qt::ImageConversionFlags flags) 63 118 { 64 constQImage image = QImageReader(fileName, format).read();119 QImage image = QImageReader(fileName, format).read(); 65 120 if (image.isNull()) 66 return; 67 68 fromImage(image, flags); 121 return false; 122 fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); 123 return !isNull(); 124 } 125 126 bool QPixmapData::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) 127 { 128 QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len); 129 QBuffer b(&a); 130 b.open(QIODevice::ReadOnly); 131 QImage image = QImageReader(&b, format).read(); 132 fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); 133 return !isNull(); 69 134 } 70 135 … … 72 137 { 73 138 fromImage(data->toImage().copy(rect), Qt::AutoColor); 139 } 140 141 bool QPixmapData::scroll(int dx, int dy, const QRect &rect) 142 { 143 Q_UNUSED(dx); 144 Q_UNUSED(dy); 145 Q_UNUSED(rect); 146 return false; 74 147 } 75 148 … … 129 202 return QBitmap(); 130 203 131 mask.set NumColors(2);204 mask.setColorCount(2); 132 205 mask.setColor(0, QColor(Qt::color0).rgba()); 133 206 mask.setColor(1, QColor(Qt::color1).rgba()); … … 177 250 } 178 251 252 #if defined(Q_OS_SYMBIAN) 253 void* QPixmapData::toNativeType(NativeType /* type */) 254 { 255 return 0; 256 } 257 258 void QPixmapData::fromNativeType(void* /* pixmap */, NativeType /* typre */) 259 { 260 return; 261 } 262 #endif 263 179 264 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.