261 } |
261 } |
262 if (device && !device->isSequential()) |
262 if (device && !device->isSequential()) |
263 device->seek(pos); |
263 device->seek(pos); |
264 } |
264 } |
265 |
265 |
266 if (!handler && !testFormat.isEmpty() && autoDetectImageFormat && !ignoresFormatAndExtension) { |
266 if (!handler && !testFormat.isEmpty() && !ignoresFormatAndExtension) { |
267 // check if any plugin supports the format (they are not allowed to |
267 // check if any plugin supports the format (they are not allowed to |
268 // read from the device yet). |
268 // read from the device yet). |
269 const qint64 pos = device ? device->pos() : 0; |
269 const qint64 pos = device ? device->pos() : 0; |
270 for (int i = 0; i < keys.size(); ++i) { |
270 |
271 if (i != suffixPluginIndex) { |
271 if (autoDetectImageFormat) { |
272 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); |
272 for (int i = 0; i < keys.size(); ++i) { |
273 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { |
273 if (i != suffixPluginIndex) { |
|
274 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); |
|
275 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { |
274 #ifdef QIMAGEREADER_DEBUG |
276 #ifdef QIMAGEREADER_DEBUG |
275 qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; |
277 qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; |
276 #endif |
278 #endif |
277 handler = plugin->create(device, testFormat); |
279 handler = plugin->create(device, testFormat); |
278 break; |
280 break; |
|
281 } |
279 } |
282 } |
|
283 } |
|
284 } else { |
|
285 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QLatin1String(testFormat))); |
|
286 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { |
|
287 #ifdef QIMAGEREADER_DEBUG |
|
288 qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format"; |
|
289 #endif |
|
290 handler = plugin->create(device, testFormat); |
280 } |
291 } |
281 } |
292 } |
282 if (device && !device->isSequential()) |
293 if (device && !device->isSequential()) |
283 device->seek(pos); |
294 device->seek(pos); |
284 } |
295 } |
|
296 |
285 #endif // QT_NO_LIBRARY |
297 #endif // QT_NO_LIBRARY |
286 |
298 |
287 // if we don't have a handler yet, check if we have built-in support for |
299 // if we don't have a handler yet, check if we have built-in support for |
288 // the format |
300 // the format |
289 if (!handler && !testFormat.isEmpty()) { |
301 if (!handler && !testFormat.isEmpty()) { |
1212 return false; |
1223 return false; |
1213 return d->handler->jumpToImage(imageNumber); |
1224 return d->handler->jumpToImage(imageNumber); |
1214 } |
1225 } |
1215 |
1226 |
1216 /*! |
1227 /*! |
1217 For image formats that support animation, this function returns |
1228 For image formats that support animation, this function returns the number |
1218 the number of times the animation should loop. Otherwise, it |
1229 of times the animation should loop. If this function returns -1, it can |
1219 returns -1. |
1230 either mean the animation should loop forever, or that an error occurred. |
1220 |
1231 If an error occurred, canRead() will return false. |
1221 \sa supportsAnimation(), QImageIOHandler::loopCount() |
1232 |
|
1233 \sa supportsAnimation(), QImageIOHandler::loopCount(), canRead() |
1222 */ |
1234 */ |
1223 int QImageReader::loopCount() const |
1235 int QImageReader::loopCount() const |
1224 { |
1236 { |
1225 if (!d->initHandler()) |
1237 if (!d->initHandler()) |
1226 return -1; |
1238 return -1; |
1227 return d->handler->loopCount(); |
1239 return d->handler->loopCount(); |
1228 } |
1240 } |
1229 |
1241 |
1230 /*! |
1242 /*! |
1231 For image formats that support animation, this function returns |
1243 For image formats that support animation, this function returns the total |
1232 the total number of images in the animation. |
1244 number of images in the animation. If the format does not support |
1233 |
1245 animation, 0 is returned. |
1234 Certain animation formats do not support this feature, in which |
1246 |
1235 case 0 is returned. |
1247 This function returns -1 if an error occurred. |
1236 |
1248 |
1237 \sa supportsAnimation(), QImageIOHandler::imageCount() |
1249 \sa supportsAnimation(), QImageIOHandler::imageCount(), canRead() |
1238 */ |
1250 */ |
1239 int QImageReader::imageCount() const |
1251 int QImageReader::imageCount() const |
1240 { |
1252 { |
1241 if (!d->initHandler()) |
1253 if (!d->initHandler()) |
1242 return -1; |
1254 return -1; |
1243 return d->handler->imageCount(); |
1255 return d->handler->imageCount(); |
1244 } |
1256 } |
1245 |
1257 |
1246 /*! |
1258 /*! |
1247 For image formats that support animation, this function returns |
1259 For image formats that support animation, this function returns the number |
1248 the number of milliseconds to wait until displaying the next frame |
1260 of milliseconds to wait until displaying the next frame in the animation. |
1249 in the animation. Otherwise, 0 is returned. |
1261 If the image format doesn't support animation, 0 is returned. |
1250 |
1262 |
1251 \sa supportsAnimation(), QImageIOHandler::nextImageDelay() |
1263 This function returns -1 if an error occurred. |
|
1264 |
|
1265 \sa supportsAnimation(), QImageIOHandler::nextImageDelay(), canRead() |
1252 */ |
1266 */ |
1253 int QImageReader::nextImageDelay() const |
1267 int QImageReader::nextImageDelay() const |
1254 { |
1268 { |
1255 if (!d->initHandler()) |
1269 if (!d->initHandler()) |
1256 return -1; |
1270 return -1; |
1257 return d->handler->nextImageDelay(); |
1271 return d->handler->nextImageDelay(); |
1258 } |
1272 } |
1259 |
1273 |
1260 /*! |
1274 /*! |
1261 For image formats that support animation, this function returns |
1275 For image formats that support animation, this function returns the |
1262 the sequence number of the current frame. Otherwise, -1 is |
1276 sequence number of the current frame. If the image format doesn't support |
1263 returned. |
1277 animation, 0 is returned. |
1264 |
1278 |
1265 \sa supportsAnimation(), QImageIOHandler::currentImageNumber() |
1279 This function returns -1 if an error occurred. |
|
1280 |
|
1281 \sa supportsAnimation(), QImageIOHandler::currentImageNumber(), canRead() |
1266 */ |
1282 */ |
1267 int QImageReader::currentImageNumber() const |
1283 int QImageReader::currentImageNumber() const |
1268 { |
1284 { |
1269 if (!d->initHandler()) |
1285 if (!d->initHandler()) |
1270 return -1; |
1286 return -1; |