2 Attachment(s)
Why antialiasing do not working for QML Image?
Hello!
This is my code:
Code:
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
id: r0
anchors.fill: parent
color: "Black"
Image {
id: bi
source: "qrc:///3.png"
anchors.centerIn: parent
visible: true
antialiasing: true
}
}
}
I set antialiasing to true, but my .png on screen has a raggy boundary. Antialiasing do not working! Why?
My .png:
Attachment 12388
On screen:
Attachment 12389
Re: Why antialiasing do not working for QML Image?
"antialiasing" is a property of Item, each subclass can handle this differently depending on its capabilities.
For Image that means that an SVG source is rendered with antialiasing, a pixel based source can only be displayed as it is.
If the only thing you need is a colored circle, you can do that with a Rectangle and its radius property or a custom item derived from QQuickPaintedItem
Cheers,
_
Re: Why antialiasing do not working for QML Image?
Quote:
Originally Posted by
anda_skoa
"antialiasing" is a property of Item, each subclass can handle this differently depending on its capabilities.
For Image that means that an SVG source is rendered with antialiasing, a pixel based source can only be displayed as it is.
If the only thing you need is a colored circle, you can do that with a Rectangle and its radius property or a custom item derived from
QQuickPaintedItem
Cheers,
_
Hello! Thank you! But it's very strange that antialiasing is performed only for svg. There is not a word in the documentation about this. That is, if I want a button of complex shape superimposed on an arbitrary background image, then the images must necessarily be in SVG format? Then why do we need all the other formats? May be it is bug?
Re: Why antialiasing do not working for QML Image?
Quote:
Originally Posted by
svv
Hello! Thank you! But it's very strange that antialiasing is performed only for svg.
Not strange at all, actually :)
Antialiasing can only be done when drawing.
An SVG source is rendered on loading, a pixel based image is loaded as-is.
Quote:
Originally Posted by
svv
There is not a word in the documentation about this.
I guess it assumes that since it is a base class property, it is understood that different subclasses might handle it differently, depending on what they visualize, and in the case of Image that a pixel based image will be presented as-is.
Quote:
Originally Posted by
svv
That is, if I want a button of complex shape superimposed on an arbitrary background image, then the images must necessarily be in SVG format?
The use case for SVG is arbitrary scaling, i.e. the sourceSize property controls how large the SVG vector data will be rendered.
That makes it possible to "scale" without losing precision
Quote:
Originally Posted by
svv
Then why do we need all the other formats?
Not sure what you mean.
There are many formats for image content an application might want to display: e.g. PNG, JPEG, etc.
Image formats are handled by plugins and Qt supports quite a number of them by default.
Cheers,
_