From f0cad9b612d0bc9d11819960f85c2f99c3dbebde Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 12 Jan 2018 14:21:19 +0100 Subject: Doc: Clarify auto detection of file format in QImage The documentation of the QImage file loader methods contained a simplified and somewhat misleading description of the format auto detection algorithm. Fix up the language and link to the detailed explanation. Task-number: QTBUG-51596 Task-number: QTBUG-65438 Change-Id: I33ebc81c78e685c7ec4803fa56efd4e9cbc4eda5 Reviewed-by: Venugopal Shivashankar --- src/gui/image/qimage.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 43b77a862d..bd10012bf6 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -931,7 +931,8 @@ QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Forma The loader attempts to read the image using the specified \a format. If the \a format is not specified (which is the default), - the loader probes the file for a header to guess the file format. + it is auto-detected based on the file's suffix and header. For + details, see {QImageReader::setAutoDetectImageFormat()}{QImageReader}. If the loading of the image failed, this object is a null image. @@ -3389,8 +3390,9 @@ void QImage::rgbSwapped_inplace() and returns \c false. The loader attempts to read the image using the specified \a format, e.g., - PNG or JPG. If \a format is not specified (which is the default), the - loader probes the file for a header to guess the file format. + PNG or JPG. If \a format is not specified (which is the default), it is + auto-detected based on the file's suffix and header. For details, see + {QImageReader::setAutoDetectImageFormat()}{QImageReader}. The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the @@ -3457,14 +3459,10 @@ bool QImage::loadFromData(const uchar *data, int len, const char *format) Constructs a QImage from the first \a size bytes of the given binary \a data. The loader attempts to read the image using the specified \a format. If \a format is not specified (which is the default), - the loader probes the file for a header to guess the file format. - binary \a data. The loader attempts to read the image, either using the - optional image \a format specified or by determining the image format from - the data. - - If \a format is not specified (which is the default), the loader probes the - file for a header to determine the file format. If \a format is specified, - it must be one of the values returned by QImageReader::supportedImageFormats(). + the loader probes the data for a header to guess the file format. + + If \a format is specified, it must be one of the values returned by + QImageReader::supportedImageFormats(). If the loading of the image fails, the image returned will be a null image. -- cgit v1.2.3