Changeset 561 for trunk/src/gui/image/qimagereader.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/qimagereader.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 ** … … 48 48 49 49 \reentrant 50 \ingroup multimedia50 \ingroup painting 51 51 \ingroup io 52 52 … … 196 196 197 197 static QImageIOHandler *createReadHandlerHelper(QIODevice *device, 198 const QByteArray &format, bool autoDetectImageFormat) 198 const QByteArray &format, 199 bool autoDetectImageFormat, 200 bool ignoresFormatAndExtension) 199 201 { 200 202 if (!autoDetectImageFormat && format.isEmpty()) … … 218 220 #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) 219 221 int suffixPluginIndex = -1; 220 if (device && format.isEmpty() && autoDetectImageFormat ) {222 if (device && format.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) { 221 223 // if there's no format, see if \a device is a file, and if so, find 222 224 // the file suffix and find support for that format among our plugins. … … 241 243 242 244 QByteArray testFormat = !form.isEmpty() ? form : suffix; 245 246 if (ignoresFormatAndExtension) 247 testFormat = QByteArray(); 243 248 244 249 #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) … … 259 264 } 260 265 261 if (!handler && !testFormat.isEmpty() && autoDetectImageFormat ) {266 if (!handler && !testFormat.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) { 262 267 // check if any plugin supports the format (they are not allowed to 263 268 // read from the device yet). … … 316 321 317 322 #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) 318 if (!handler && autoDetectImageFormat) {323 if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) { 319 324 // check if any of our plugins recognize the file from its contents. 320 325 const qint64 pos = device ? device->pos() : 0; … … 336 341 #endif 337 342 338 if (!handler && autoDetectImageFormat) {343 if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) { 339 344 // check if any of our built-in handlers recognize the file from its 340 345 // contents. … … 435 440 QByteArray format; 436 441 bool autoDetectImageFormat; 442 bool ignoresFormatAndExtension; 437 443 QIODevice *device; 438 444 bool deleteDevice; … … 459 465 */ 460 466 QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq) 461 : autoDetectImageFormat(true) 467 : autoDetectImageFormat(true), ignoresFormatAndExtension(false) 462 468 { 463 469 device = 0; … … 466 472 quality = -1; 467 473 imageReaderError = QImageReader::UnknownError; 468 errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unknown error"));469 474 470 475 q = qq; … … 523 528 524 529 // assign a handler 525 if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat )) == 0) {530 if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) { 526 531 imageReaderError = QImageReader::UnsupportedFormatError; 527 532 errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unsupported image format")); … … 665 670 when trying to read the image. 666 671 667 \endlist 672 \endlist 668 673 669 674 By disabling image format autodetection, QImageReader will only query the … … 682 687 reader; otherwise returns false. By default, autodetection is enabled. 683 688 684 \sa setAutoDetectImageFormat() 689 \sa setAutoDetectImageFormat() 685 690 */ 686 691 bool QImageReader::autoDetectImageFormat() const … … 688 693 return d->autoDetectImageFormat; 689 694 } 695 696 697 /*! 698 If \a ignored is set to true, then the image reader will ignore 699 specified formats or file extensions and decide which plugin to 700 use only based on the contents in the datastream. 701 702 Setting this flag means that all image plugins gets loaded. Each 703 plugin will read the first bytes in the image data and decide if 704 the plugin is compatible or not. 705 706 This also disables auto detecting the image format. 707 708 \sa decideFormatFromContent() 709 */ 710 711 void QImageReader::setDecideFormatFromContent(bool ignored) 712 { 713 d->ignoresFormatAndExtension = ignored; 714 } 715 716 717 /*! 718 Returns whether the image reader should decide which plugin to use 719 only based on the contents of the datastream rather than on the file 720 extension. 721 722 \sa setDecideFormatFromContent() 723 */ 724 725 bool QImageReader::decideFormatFromContent() const 726 { 727 return d->ignoresFormatAndExtension; 728 } 729 690 730 691 731 /*! … … 1174 1214 1175 1215 /*! 1176 For image formats that support animation, this function returns 1177 the number of times the animation should loop. Otherwise, it 1178 returns -1. 1179 1180 \sa supportsAnimation(), QImageIOHandler::loopCount() 1216 For image formats that support animation, this function returns the number 1217 of times the animation should loop. If this function returns -1, it can 1218 either mean the animation should loop forever, or that an error occurred. 1219 If an error occurred, canRead() will return false. 1220 1221 \sa supportsAnimation(), QImageIOHandler::loopCount(), canRead() 1181 1222 */ 1182 1223 int QImageReader::loopCount() const … … 1188 1229 1189 1230 /*! 1190 For image formats that support animation, this function returns 1191 the total number of images in the animation.1192 1193 Certain animation formats do not support this feature, in which 1194 case 0 is returned.1195 1196 \sa supportsAnimation(), QImageIOHandler::imageCount() 1231 For image formats that support animation, this function returns the total 1232 number of images in the animation. If the format does not support 1233 animation, 0 is returned. 1234 1235 This function returns -1 if an error occurred. 1236 1237 \sa supportsAnimation(), QImageIOHandler::imageCount(), canRead() 1197 1238 */ 1198 1239 int QImageReader::imageCount() const … … 1204 1245 1205 1246 /*! 1206 For image formats that support animation, this function returns 1207 the number of milliseconds to wait until displaying the next frame 1208 in the animation. Otherwise, 0 is returned. 1209 1210 \sa supportsAnimation(), QImageIOHandler::nextImageDelay() 1247 For image formats that support animation, this function returns the number 1248 of milliseconds to wait until displaying the next frame in the animation. 1249 If the image format doesn't support animation, 0 is returned. 1250 1251 This function returns -1 if an error occurred. 1252 1253 \sa supportsAnimation(), QImageIOHandler::nextImageDelay(), canRead() 1211 1254 */ 1212 1255 int QImageReader::nextImageDelay() const … … 1218 1261 1219 1262 /*! 1220 For image formats that support animation, this function returns 1221 the sequence number of the current frame. Otherwise, -1 is 1222 returned. 1223 1224 \sa supportsAnimation(), QImageIOHandler::currentImageNumber() 1263 For image formats that support animation, this function returns the 1264 sequence number of the current frame. If the image format doesn't support 1265 animation, 0 is returned. 1266 1267 This function returns -1 if an error occurred. 1268 1269 \sa supportsAnimation(), QImageIOHandler::currentImageNumber(), canRead() 1225 1270 */ 1226 1271 int QImageReader::currentImageNumber() const … … 1262 1307 QString QImageReader::errorString() const 1263 1308 { 1309 if (d->errorString.isEmpty()) 1310 return QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unknown error")); 1264 1311 return d->errorString; 1265 1312 } … … 1310 1357 { 1311 1358 QByteArray format; 1312 QImageIOHandler *handler = createReadHandlerHelper(device, format, /* autoDetectImageFormat = */ true );1359 QImageIOHandler *handler = createReadHandlerHelper(device, format, /* autoDetectImageFormat = */ true, false); 1313 1360 if (handler) { 1314 1361 if (handler->canRead()) … … 1338 1385 \row \o XBM \o X11 Bitmap 1339 1386 \row \o XPM \o X11 Pixmap 1387 \row \o SVG \o Scalable Vector Graphics 1340 1388 \endtable 1341 1389
Note:
See TracChangeset
for help on using the changeset viewer.