Changeset 561 for trunk/src/gui/image/qpixmap_raster.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/qpixmap_raster.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 ** … … 51 51 #include <private/qdrawhelper_p.h> 52 52 53 #if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN)54 #include <private/qpaintengine_d3d_p.h>55 #include <d3d9.h>56 extern QDirect3DPaintEngine *qt_d3dEngine();57 #endif58 59 53 QT_BEGIN_NAMESPACE 60 54 … … 62 56 0x10, 0x20, 0x40, 0x80 }; 63 57 58 QPixmap qt_toRasterPixmap(const QImage &image) 59 { 60 QPixmapData *data = 61 new QRasterPixmapData(image.depth() == 1 62 ? QPixmapData::BitmapType 63 : QPixmapData::PixmapType); 64 65 data->fromImage(image, Qt::AutoColor); 66 67 return QPixmap(data); 68 } 69 70 QPixmap qt_toRasterPixmap(const QPixmap &pixmap) 71 { 72 if (pixmap.isNull()) 73 return QPixmap(); 74 75 if (QPixmap(pixmap).data_ptr()->classId() == QPixmapData::RasterClass) 76 return pixmap; 77 78 return qt_toRasterPixmap(pixmap.toImage()); 79 } 80 64 81 QRasterPixmapData::QRasterPixmapData(PixelType type) 65 82 : QPixmapData(type, RasterClass) 66 #if defined(Q_WS_WIN) && !defined(QT_NO_DIRECT3D)67 , texture(0)68 #endif69 83 { 70 84 } … … 72 86 QRasterPixmapData::~QRasterPixmapData() 73 87 { 88 } 89 90 QPixmapData *QRasterPixmapData::createCompatiblePixmapData() const 91 { 92 return new QRasterPixmapData(pixelType()); 74 93 } 75 94 … … 95 114 96 115 image = QImage(width, height, format); 116 w = width; 117 h = height; 118 d = image.depth(); 119 is_null = (w <= 0 || h <= 0); 97 120 98 121 if (pixelType() == BitmapType && !image.isNull()) { 99 image.set NumColors(2);122 image.setColorCount(2); 100 123 image.setColor(0, QColor(Qt::color0).rgba()); 101 124 image.setColor(1, QColor(Qt::color1).rgba()); … … 178 201 } 179 202 #endif 203 if (image.d) { 204 w = image.d->width; 205 h = image.d->height; 206 d = image.d->depth; 207 } else { 208 w = h = d = 0; 209 } 210 is_null = (w <= 0 || h <= 0); 180 211 181 212 setSerialNumber(image.serialNumber()); 213 } 214 215 // from qwindowsurface.cpp 216 extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); 217 218 bool QRasterPixmapData::scroll(int dx, int dy, const QRect &rect) 219 { 220 if (!image.isNull()) 221 qt_scrollRectInImage(image, rect, QPoint(dx, dy)); 222 return true; 182 223 } 183 224 … … 322 363 int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const 323 364 { 365 QImageData *d = image.d; 366 if (!d) 367 return 0; 368 324 369 // override the image dpi with the screen dpi when rendering to a pixmap 325 const int dpmX = qRound(qt_defaultDpiX() * 100 / qreal(2.54));326 const int dpmY = qRound(qt_defaultDpiY() * 100 / qreal(2.54));327 370 switch (metric) { 371 case QPaintDevice::PdmWidth: 372 return w; 373 case QPaintDevice::PdmHeight: 374 return h; 328 375 case QPaintDevice::PdmWidthMM: 329 return qRound( image.width() * 1000 / dpmX);376 return qRound(d->width * 25.4 / qt_defaultDpiX()); 330 377 case QPaintDevice::PdmHeightMM: 331 return qRound(image.height() * 1000 / dpmY); 332 case QPaintDevice::PdmDpiX: 333 return qRound(dpmX * qreal(0.0254)); 334 case QPaintDevice::PdmDpiY: 335 return qRound(dpmY * qreal(0.0254)); 378 return qRound(d->height * 25.4 / qt_defaultDpiY()); 379 case QPaintDevice::PdmNumColors: 380 return d->colortable.size(); 381 case QPaintDevice::PdmDepth: 382 return this->d; 383 case QPaintDevice::PdmDpiX: // fall-through 336 384 case QPaintDevice::PdmPhysicalDpiX: 337 return qRound(dpmX * qreal(0.0254)); 385 return qt_defaultDpiX(); 386 case QPaintDevice::PdmDpiY: // fall-through 338 387 case QPaintDevice::PdmPhysicalDpiY: 339 return q Round(dpmY * qreal(0.0254));388 return qt_defaultDpiY(); 340 389 default: 341 return image.metric(metric); 342 } 390 qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric); 391 break; 392 } 393 394 return 0; 343 395 } 344 396
Note:
See TracChangeset
for help on using the changeset viewer.