Qt 4.8
Classes | Functions | Variables
qimagewriter.cpp File Reference
#include "qimagewriter.h"
#include <qbytearray.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qimageiohandler.h>
#include <qset.h>
#include <qvariant.h>
#include <qcoreapplication.h>
#include <private/qfactoryloader_p.h>
#include <private/qbmphandler_p.h>
#include <private/qppmhandler_p.h>
#include <private/qxbmhandler_p.h>
#include <private/qxpmhandler_p.h>
#include <private/qpnghandler_p.h>
#include <private/qjpeghandler_p.h>
#include <private/qmnghandler_p.h>
#include <private/qtiffhandler_p.h>

Go to the source code of this file.

Classes

class  QImageWriterPrivate
 

Functions

 if (device &&format.isEmpty())
 
 if (suffixPluginIndex !=-1)
 
 if (!handler &&!testFormat.isEmpty())
 
 if (!testFormat.isEmpty())
 
 if (!handler) return 0
 
 Q_GLOBAL_STATIC_WITH_ARGS (QFactoryLoader, loader,(QImageIOHandlerFactoryInterface_iid, QLatin1String("/imageformats"))) static QImageIOHandler *createWriteHandlerHelper(QIODevice *device
 
handler setDevice (device)
 

Variables

const QByteArrayformat
 
QImageIOHandlerhandler = 0
 
QStringList keys = l->keys()
 
QFactoryLoaderl = loader()
 
QByteArray suffix
 
int suffixPluginIndex = -1
 
QByteArray testFormat = !form.isEmpty() ? form : suffix
 

Function Documentation

◆ if() [1/5]

if ( device &&format.  isEmpty())

Definition at line 157 of file qimagewriter.cpp.

157  {
158  // if there's no format, see if \a device is a file, and if so, find
159  // the file suffix and find support for that format among our plugins.
160  // this allows plugins to override our built-in handlers.
161  if (QFile *file = qobject_cast<QFile *>(device)) {
162  if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) {
163 #ifndef QT_NO_LIBRARY
165  if (index != -1)
167 #endif
168  }
169  }
170  }
int suffixPluginIndex
QByteArray toLower() const
Returns a lowercase copy of the byte array.
QStringList keys
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
Definition: qstringlist.h:195
static bool isEmpty(const char *str)
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QByteArray suffix
quint16 index
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ if() [2/5]

if ( suffixPluginIndex = -1)

Definition at line 175 of file qimagewriter.cpp.

175  {
176  // when format is missing, check if we can find a plugin for the
177  // suffix.
179  if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite))
180  handler = plugin->create(device, suffix);
181  }
virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const =0
Returns the capabilities on the plugin, based on the data in device and the format format...
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const =0
Creates and returns a QImageIOHandler subclass, with device and format set.
The QImageIOPlugin class defines an interface for writing an image format plugin. ...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QObject * instance(const QString &key) const
QByteArray suffix
QFactoryLoader * l
QImageIOHandler * handler

◆ if() [3/5]

if ( !handler &&!testFormat.  isEmpty())

Definition at line 185 of file qimagewriter.cpp.

185  {
186  if (false) {
187 #ifndef QT_NO_IMAGEFORMAT_PNG
188  } else if (testFormat == "png") {
189  handler = new QPngHandler;
190 #endif
191 #ifndef QT_NO_IMAGEFORMAT_JPEG
192  } else if (testFormat == "jpg" || testFormat == "jpeg") {
193  handler = new QJpegHandler;
194 #endif
195 #ifndef QT_NO_IMAGEFORMAT_MNG
196  } else if (testFormat == "mng") {
197  handler = new QMngHandler;
198 #endif
199 #ifndef QT_NO_IMAGEFORMAT_TIFF
200  } else if (testFormat == "tif" || testFormat == "tiff") {
201  handler = new QTiffHandler;
202 #endif
203 #ifdef QT_BUILTIN_GIF_READER
204  } else if (testFormat == "gif") {
205  handler = new QGifHandler;
206 #endif
207 #ifndef QT_NO_IMAGEFORMAT_BMP
208  } else if (testFormat == "bmp") {
209  handler = new QBmpHandler;
210 #endif
211 #ifndef QT_NO_IMAGEFORMAT_XPM
212  } else if (testFormat == "xpm") {
213  handler = new QXpmHandler;
214 #endif
215 #ifndef QT_NO_IMAGEFORMAT_XBM
216  } else if (testFormat == "xbm") {
217  handler = new QXbmHandler;
219 #endif
220 #ifndef QT_NO_IMAGEFORMAT_PPM
221  } else if (testFormat == "pbm" || testFormat == "pbmraw" || testFormat == "pgm"
222  || testFormat == "pgmraw" || testFormat == "ppm" || testFormat == "ppmraw") {
223  handler = new QPpmHandler;
225 #endif
226  }
227  }
virtual void setOption(ImageOption option, const QVariant &value)
Sets the option option with the value value.
QByteArray testFormat
QImageIOHandler * handler

◆ if() [4/5]

if ( !testFormat.  isEmpty())

Definition at line 230 of file qimagewriter.cpp.

230  {
231  for (int i = 0; i < keys.size(); ++i) {
233  if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) {
234  delete handler;
235  handler = plugin->create(device, testFormat);
236  break;
237  }
238  }
239  }
virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const =0
Returns the capabilities on the plugin, based on the data in device and the format format...
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QStringList keys
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QByteArray testFormat
virtual QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const =0
Creates and returns a QImageIOHandler subclass, with device and format set.
The QImageIOPlugin class defines an interface for writing an image format plugin. ...
QObject * instance(const QString &key) const
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l
QImageIOHandler * handler

◆ if() [5/5]

if ( handler)

Definition at line 585 of file qcocoasharedwindowmethods_mac_p.h.

585  {
586  // There is no toolbar, we have to draw a line on top of the line drawn by Cocoa.
587  macDrawRectOnTop((void *)window);
588  } else {
NSWindow * window

◆ Q_GLOBAL_STATIC_WITH_ARGS()

Q_GLOBAL_STATIC_WITH_ARGS ( QFactoryLoader  ,
loader  ,
(QImageIOHandlerFactoryInterface_iid, QLatin1String("/imageformats"))   
)

◆ setDevice()

handler setDevice ( device  )

Variable Documentation

◆ format

Initial value:
{
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray toLower() const
Returns a lowercase copy of the byte array.

Definition at line 145 of file qimagewriter.cpp.

◆ handler

return handler = 0

◆ keys

QStringList keys = l->keys()

◆ l

QFactoryLoader* l = loader()

Definition at line 152 of file qimagewriter.cpp.

Referenced by QDateTimeEditPrivate::_q_editorCursorPositionChanged(), QHeaderViewPrivate::_q_sectionsRemoved(), _qdtoa(), QWSSoundServerProvider::add(), QLayout::addChildWidget(), QTessellatorPrivate::addEdges(), QBezier::addToPolygon(), QSystemTrayIconSys::addToTray(), QGridLayout::addWidget(), Graph< AnchorVertex, AnchorData >::adjacentVertices(), QTextCursorPrivate::adjustCursor(), QPatternist::NamePool::allocateBinding(), QPatternist::NamePool::allocateLocalName(), QPatternist::NamePool::allocateNamespace(), QPatternist::NamePool::allocatePrefix(), QPatternist::NamePool::allocateQName(), QJpUnicodeConv::asciiToUnicode(), QTextCodec::availableCodecs(), QAudioDeviceFactory::availableDevices(), QTextCodec::availableMibs(), QVector< QPoint >::back(), blend_color_generic(), blend_tiled_argb(), blend_tiled_generic(), blend_transformed_argb(), blend_transformed_tiled_argb(), blend_untransformed_generic(), blendTiled(), blendTransformed(), blendTransformedBilinear(), blendTransformedTiled(), bm_find(), bm_init_skiptable(), QLocalePrivate::bytearrayToLongLong(), QLocalePrivate::bytearrayToUnsLongLong(), QTextCodec::canEncode(), canonicalOrderHelper(), QPicturePrivate::checkFormat(), childKeysOrGroups(), QLayout::closestAcceptableSize(), QRect::contains(), QRectF::contains(), QWindowsMimeURI::convertFromMime(), createForName(), QTextLayout::createLine(), createReadHandlerHelper(), QLineControl::cursorRect(), QTextLine::cursorToX(), QOpenGLPaintEnginePrivate::curveToStencil(), QGIFFormat::decode(), QListData::detach_grow(), QAudioOutputPrivate::deviceReady(), QPatternist::NamePool::displayName(), QGIFFormat::disposePrevious(), do_size_hints(), QEventDispatcherUNIXPrivate::doSelect(), QTextLayout::draw(), QTextDocumentLayoutPrivate::drawBlock(), QMacStyle::drawControl(), QTextLayout::drawCursor(), QPainter::drawLine(), QOpenGLPaintEngine::drawLines(), QRasterPaintEngine::drawLines(), drawLines(), QX11PaintEngine::drawRects(), QMatrix::dy(), QTessellatorPrivate::edgeInChain(), QTriangulator< T >::ComplexToSimple::edgeIsLeftOfEdge(), QTriangulator< T >::SimpleToMonotone::edgeIsLeftOfEdge(), QBoxLayoutPrivate::effectiveMargins(), QGridLayoutPrivate::effectiveMargins(), QTextLayout::endLayout(), QPlainTextEditPrivate::ensureVisible(), QTestEventLoop::enterLoop(), QDir::entryInfoList(), QDir::entryList(), equal(), QVarLengthArray< QVariant, 9 >::erase(), QVector< QPoint >::erase(), escapedKey(), QWindowsStyle::eventFilter(), QDeclarativeBindingCompilerPrivate::exceptionId(), extractEncodingDecl(), QDeclarativeScriptParser::extractMetaData(), QDeclarativeScriptParser::extractPragmas(), QWSSoundServerPrivate::feedDevice(), QDeclarativeImportedNamespace::find(), QDateTimeParser::findDay(), QDateTimeParser::findMonth(), QResourceRoot::findNode(), QToolBarAreaLayoutInfo::fitLayout(), QFontInfo::fixedPitch(), QAudioOutputPrivate::freeBlocks(), QAudioInputPrivate::freeBlocks(), QFont::fromString(), getMacDateFormat(), getMacLocaleName(), getMacTimeFormat(), QDeclarativeParser::Property::getValue(), QFontSubset::glyphName(), good_offset(), handle_xdnd_position(), handle_xdnd_status(), handleSpans(), QGraphicsLayoutItemPrivate::hasHeightForWidth(), QIntersectionFinder::hasIntersections(), QGraphicsLayoutItemPrivate::hasWidthForHeight(), QTextDocumentLayout::hitTest(), QTextDocumentLayoutPrivate::hitTest(), QDeclarativeEnginePrivate::hsla(), QDeclarativeCompiledData::indexForLocation(), QByteArray::indexOf(), QIconModeViewBase::initBspTree(), QDirPrivate::initFileLists(), QDockWidget::initStyleOption(), jisx0201ToUnicode11(), jisx0208ToSjis(), QJpUnicodeConv::jisx0212ToUnicode(), jisx0212ToUnicode11(), QSQLiteDriverPlugin::keys(), QSQLite2DriverPlugin::keys(), QIBaseDriverPlugin::keys(), QPSQLDriverPlugin::keys(), QOCIDriverPlugin::keys(), QDB2DriverPlugin::keys(), QMYSQLDriverPlugin::keys(), QODBCDriverPlugin::keys(), QSymSQLDriverPlugin::keys(), QTDSDriverPlugin::keys(), QMetaEnum::keysToValue(), QString::lastIndexOf(), QStringRef::lastIndexOf(), QTextDocumentLayoutPrivate::layoutBlock(), QFontEngineXLFD::leading(), QFontEngineBox::leading(), QSortFilterProxyModel::lessThan(), lessThan(), QMetaType::load(), QFontEngineFT::loadGlyph(), mapToLowerCase(), QScanConverter::mergeCurve(), QToolBarAreaLayoutInfo::minimumSize(), QSplitter::minimumSizeHint(), QToolBarAreaLayoutInfo::moveToolBar(), QWindowsEnumerate::Next(), normalizedTimeval(), QLocalePrivate::numberToCLocale(), QPatternist::OperandsIterator::OperandsIterator(), QLinkedList< JSC::Identifier >::operator!=(), QList< QPostEvent >::operator!=(), QLinkedList< JSC::Identifier >::operator+(), QVector< QPoint >::operator+(), QList< QPostEvent >::operator+(), QList< QPostEvent >::operator+=(), QStandardItem::operator<(), QStringList::operator<<(), QLinkedList< JSC::Identifier >::operator<<(), operator<<(), QVector< QPoint >::operator<<(), QList< QPostEvent >::operator<<(), QImage::operator==(), operator>>(), QPlainTextEdit::paintEvent(), parse_locale_tag(), QHttpResponseHeader::parseLine(), QWorkspacePrivate::place(), QFontDatabase::pointSizes(), QTextHtmlImporter::processBlockNode(), QEventDispatcherUNIX::processEvents(), QTextHtmlImporter::processSpecialNodes(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qFindByteArray(), qFindString(), qGetODBCVersion(), QJpUnicodeConv_JISX0221_ASCII::QJpUnicodeConv_JISX0221_ASCII(), QJpUnicodeConv_JISX0221_JISX0201::QJpUnicodeConv_JISX0221_JISX0201(), QJpUnicodeConv_Microsoft::QJpUnicodeConv_Microsoft(), QJpUnicodeConv_Sun::QJpUnicodeConv_Sun(), QJpUnicodeConv_Unicode_ASCII::QJpUnicodeConv_Unicode_ASCII(), QLineF::QLineF(), QList< QPostEvent >::QList(), qScanConvert(), qSplitTableQualifier(), qt_format_text(), qt_is_idn_enabled(), qt_mac_execute_apple_script(), qt_mac_menu_event(), qt_mac_removeMnemonics(), qt_section_chunk::qt_section_chunk(), qt_set_x11_resources(), QTest::qToInt(), QTransform::QTransform(), QUuid::QUuid(), QVariant::QVariant(), QXmlParseException::QXmlParseException(), QRasterPaintEnginePrivate::rasterizeLine_dashed(), QAudioInputPrivate::read(), QIODevicePrivateLinearBuffer::readAll(), QWinSettingsPrivate::readKey(), QStatusBar::reformat(), removeGroupSeparators(), QGraphicsLayoutPrivate::reparentChildItems(), QLayoutPrivate::reparentChildWidgets(), QAccessibleDisplay::role(), QZipReaderPrivate::scanFiles(), QDateTimeParser::sectionMaxSize(), QWSServerPrivate::sendQCopEvent(), QWinSettingsPrivate::set(), QLayout::setAlignment(), QLineF::setAngle(), QGraphicsWidget::setContentsMargins(), QWidget::setContentsMargins(), QDeclarativeDataBlob::setError(), QWidgetPrivate::setFont_helper(), QWidget::setLayout(), QGraphicsWidgetPrivate::setLayout_helper(), QDeclarativeDebugFileReference::setLineNumber(), QApplicationPrivate::setMaxWindowRect(), QWSQCopSendCommand::setMessage(), QXlibWindow::setMWMHints(), SetMWMHints(), QWSRegionNameCommand::setName(), QTableView::setSelection(), QApplication::setStartDragDistance(), QWidget::setTabOrder(), QXcbWindow::setWindowFlags(), QDial::setWrapping(), QTextEngine::shapeTextMac(), shift(), QSplitter::sizeHint(), QGraphicsProxyWidget::sizeHint(), QToolBarAreaLayoutInfo::sizeHint(), QFontDatabase::smoothSizes(), QDirPrivate::sortFileList(), SoundPlayProc(), QColor::spec(), QSettingsPrivate::splitArgs(), QAccessibleLineEdit::state(), QPatternist::NamePool::stringForLocalName(), QPatternist::NamePool::stringForNamespace(), QPatternist::NamePool::stringForPrefix(), QSettingsPrivate::stringListToVariantList(), QOpenGLPaintEnginePrivate::strokePathFastPen(), QFontDatabase::styles(), QImageReader::supportedImageFormats(), QLinkedList< JSC::Identifier >::swap(), QBoxLayout::takeAt(), QFormLayout::takeAt(), QGridLayoutPrivate::takeAt(), QWidget::takeLayout(), QAccessibleDisplay::text(), timerSourcePrepareHelper(), QByteArray::toBase64(), QPatternist::NamePool::toClarkName(), QPatternist::NamePool::toLexical(), QApplication::topLevelAt(), QColor::toRgb(), QFontEngineXLFD::toUnicode(), QByteArray::trimmed(), QString::trimmed(), trimRef(), QTextUndoCommand::tryMerge(), QWSSoundServerClient::tryReadCommand(), ucstrcmp(), unicode11ToJisx0201(), unicode11ToJisx0208(), unicode11ToJisx0212(), QJpUnicodeConv::unicodeToAscii(), QGL2PaintEngineExPrivate::updateBrushUniforms(), QNetworkConfigurationManagerPrivate::updateConfigurations(), QLineControl::updateDisplayText(), QOpenGLPaintEnginePrivate::updateGradient(), QX11Data::xdndHandleDrop(), QX11Data::xdndHandleEnter(), QX11Data::xdndHandleFinished(), QX11Data::xdndHandleLeave(), xic_draw_callback(), QPatternist::yyparse(), and QLayout::~QLayout().

◆ suffix

QByteArray suffix

◆ suffixPluginIndex

int suffixPluginIndex = -1

Definition at line 154 of file qimagewriter.cpp.

Referenced by createReadHandlerHelper().

◆ testFormat

QByteArray testFormat = !form.isEmpty() ? form : suffix

Definition at line 172 of file qimagewriter.cpp.

Referenced by createReadHandlerHelper().