/*! Returns TRUE if the information in \a e can be decoded into an image. \sa decode() */ bool QImageDrag::canDecode( const QMimeSource* e ) { QStrList fileFormats = QImageIO::inputFormats(); fileFormats.first(); while ( fileFormats.current() ) { QCString format = fileFormats.current(); QCString type = "image/" + format.lower(); if ( e->provides( type.data() ) ) return TRUE; fileFormats.next(); } return FALSE; }
/*! Attempts to decode the dropped information in \a e into \a img, returning TRUE if successful. \sa canDecode() */ bool QImageDrag::decode( const QMimeSource* e, QImage& img ) { QByteArray payload; QStrList fileFormats = QImageIO::inputFormats(); // PNG is best of all if ( fileFormats.remove("PNG") ) // move to front fileFormats.insert(0,"PNG"); fileFormats.first(); while ( fileFormats.current() ) { QCString format = fileFormats.current(); QCString type = "image/" + format.lower(); payload = e->encodedData( type.data() ); if ( !payload.isEmpty() ) break; fileFormats.next(); } if ( payload.isEmpty() ) return FALSE; img.loadFromData(payload); return !img.isNull(); }
QStringList opie_imageExtensions() { /* * File extensions (e.g jpeg JPG jpg) are not * parsed yet */ if ( !opie_image_extension_List ) { opie_image_extension_List = new QStringList(); qAddPostRoutine( clean_opie_image_extension_List ); QStrList fileFormats = QImageIO::inputFormats(); QString ff = fileFormats.first(); while ( fileFormats.current() ) { *opie_image_extension_List += MimeType("image/"+ff.lower()).extensions(); ff = fileFormats.next(); } } return *opie_image_extension_List; // QShared so it should be efficient }