Results 1 to 4 of 4

Thread: Why antialiasing do not working for QML Image?

  1. #1
    Join Date
    Mar 2017
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Why antialiasing do not working for QML Image?

    Hello!

    This is my code:
    Qt Code:
    1. import QtQuick 2.6
    2. import QtQuick.Window 2.2
    3.  
    4. Window {
    5. visible: true
    6. width: 640
    7. height: 480
    8. title: qsTr("Hello World")
    9.  
    10. Rectangle {
    11. id: r0
    12. anchors.fill: parent
    13. color: "Black"
    14.  
    15. Image {
    16. id: bi
    17. source: "qrc:///3.png"
    18. anchors.centerIn: parent
    19. visible: true
    20. antialiasing: true
    21. }
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    I set antialiasing to true, but my .png on screen has a raggy boundary. Antialiasing do not working! Why?

    My .png:
    3.png

    On screen:
    result.png
    Last edited by svv; 16th March 2017 at 11:22.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  3. #3
    Join Date
    Mar 2017
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why antialiasing do not working for QML Image?

    Quote Originally Posted by anda_skoa View Post
    "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?
    Last edited by svv; 16th March 2017 at 16:59.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why antialiasing do not working for QML Image?

    Quote Originally Posted by svv View Post
    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 View Post
    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 View Post
    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 View Post
    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,
    _

Similar Threads

  1. Border-image not working in QWidget?
    By astampor in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2011, 15:16
  2. Replies: 0
    Last Post: 24th January 2011, 11:12
  3. Replies: 2
    Last Post: 5th May 2010, 06:01
  4. QPainter.drawImage() not working with resource image file
    By thiagoalencar22 in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2010, 21:07
  5. Best AntiAliasing?
    By beni46 in forum Qwt
    Replies: 2
    Last Post: 2nd February 2010, 13:28

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.