Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.5.0
-
None
Description
Right now @2x handling is spread in several places (qicon, qstylesheet, user code, etc.)
QImageReader seems a reasonable candidate to partly centralize this behavior:
- add a autoDevicePixelRatio()/setAutoDevicePixelRatio(bool) method pair.
- add AutoDevicePixelRatio to QImageIOHandler::ImageOption
- if the IO handler supports vector scaling (like the SVG handler), autoDevicePixelRatio will be handled by the IO handler, scaling the svg image to the right dpr
- otherwise, QImageReader will look for an @2x file, and if it finds it, it will read that and set the device pixel ratio to 2.0
- QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags), through QPlatformPixmap::fromFile(), will set autoDevicePixelRatio to true. This is because QPixmap is meant to be used for displaying images on screen.
- QImage(const QString & fileName, const char * format = 0) will NOT set autoDevicePixelRatio to true
- if autoDevicePixelRatio is false, QImageReader will not set the device pixel ratio on the image, irrespectively of the @2x (see QTBUG-38485)
Does this make sense? I could work on this if there is some consensus