Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [Disscussion] Which is better for mobile games, PNG or SVG?
Qt 6.12 LTS is out! See what's new in the release blog

[Disscussion] Which is better for mobile games, PNG or SVG?

Scheduled Pinned Locked Moved Game Development
12 Posts 4 Posters 14.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #2

    PNG is the way to go. You can use SVG internally to get good quality, but the resulting game should be using PNGs. Reason is quite simple: displaying (parsing and drawing) SVG files takes a lot more time (IIRC, time is a few orders of magnitude longer).

    (Z(:^

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      q8phantom
      wrote on last edited by
      #3

      [quote author="sierdzio" date="1328868566"]PNG is the way to go. You can use SVG internally to get good quality, but the resulting game should be using PNGs. Reason is quite simple: displaying (parsing and drawing) SVG files takes a lot more time (IIRC, time is a few orders of magnitude longer).[/quote]

      The thing is I liked the way how you can make Sprite sheets easliy in SVG

      Also, the rumor about the new screen res of the iPad 3, am creating screen res independent games :)

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #4

        I know, it would be nice and easy to go with SVG, but it seems that the choice is this:

        • either go with PNG and go through pain of generating separate files for various resolutions
        • or try SVG and suffer from performance loses (or, if the amount of SVG content is not too large, the battery might get hit even though performance would stay decent)

        (Z(:^

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #5

          Anyway, you can try benchmarking both approaches to see what is the real difference. I've seen comparison somewhere, but can't seem to be able to find it now.

          (Z(:^

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            q8phantom
            wrote on last edited by
            #6

            Ok, let's ask another question,

            In both cases, I'm scaling my images!

            In PNGs, I scale images to a percentage where it looks good on screen.

            So I will do in SVGs

            BTW, I'm searching the internet for SVG Files to do comparison

            Bests

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #7

              take any Linux icon pack, they're full of SVGs, and usually come with prerendered PNGs, too.

              (Z(:^

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #8

                You can have images saved as SVG and when you start your game, you resize them to desired resolution and save them ( only to RAM) as png or bmp ( preferably to bmp for better performance) with which your work with.

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  q8phantom
                  wrote on last edited by
                  #9

                  Thank you that's a great idea

                  [quote author="Jake007" date="1328980764"]You can have images saved as SVG and when you start your game, you resize them to desired resolution and save them ( only to RAM) as png or bmp ( preferably to bmp for better performance) with which your work with. [/quote]

                  Anyways I have made a comparison if anyone want source code let me know.

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    q8phantom
                    wrote on last edited by
                    #10

                    Can anyone give me hints on how to resize the an svg and then convert it

                    I will appreciate a code snippet

                    Bests

                    1 Reply Last reply
                    0
                    • Q Offline
                      Q Offline
                      q8phantom
                      wrote on last edited by
                      #11

                      Code snippet

                      You can multiply the size to any size you like for the SVG Item or set the size customly in the QPixmap constructor

                      Bests

                      @ QSvgRenderer renderer;
                      renderer.load(QLatin1String("Head.svg"));
                      QPixmap image(renderer.defaultSize()2);
                      image.fill(Qt::transparent);
                      QPainter painter(&image);
                      renderer.render(&painter);
                      QGraphicsPixmapItem
                      item = new QGraphicsPixmapItem(image);
                      @

                      1 Reply Last reply
                      0
                      • GianlucaG Offline
                        GianlucaG Offline
                        Gianluca
                        wrote on last edited by
                        #12

                        Hello,
                        I read this discussion, and I like the hybrid approach to load the .svg and convert them to pixmap and then render it.
                        Because, it is seems a very good approach for get a perfect balance between the resolution independence of .svg with the speed of drawing of a pixmap...
                        I'm wondering if the QML Image item use this approach when you set a .svg image as source ...
                        anyone know the performances of QML Image item on .svg images ??

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt
                        • Unsolved