Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [Disscussion] Which is better for mobile games, PNG or SVG?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Game Development
12 Posts 4 Posters 11.2k Views
  • 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.
  • Q Offline
    Q Offline
    q8phantom
    wrote on 10 Feb 2012, 09:58 last edited by
    #1

    I want to make several 2D games for mobile platforms, mainly using Qt for iOS, Android, Symbian, MeeGo and whatever supported by Qt (WP7?).

    I've made one game already using PNGs. (Card game : Dewan of kout )
    http://itunes.apple.com/us/app/dewan-of-kout/id491157833?mt=8
    http://store.ovi.com/content/208820

    I'm thinking of making a game similar to that one, and also another game similar to "battleheart":http://www.youtube.com/watch?v=0VqlJ_AvFS8

    What do you think is the best option, PNG files or SVG files or other formats? Which is better for mobile games, PNG or SVG?

    and BTW, I'm using QGraphicsView with bunch of QGraphicsPixmapItem

    Bests
    Ahmed

    1 Reply Last reply
    1
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 10 Feb 2012, 10:09 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
      1
      • Q Offline
        Q Offline
        q8phantom
        wrote on 10 Feb 2012, 10:40 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
        1
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 10 Feb 2012, 12:45 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
          1
          • S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 10 Feb 2012, 12:46 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 11 Feb 2012, 09:12 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
              • S Offline
                S Offline
                sierdzio
                Moderators
                wrote on 11 Feb 2012, 16:37 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
                • J Offline
                  J Offline
                  Jake007
                  wrote on 11 Feb 2012, 17:19 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.


                  Code is poetry

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    q8phantom
                    wrote on 11 Feb 2012, 18:15 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 12 Feb 2012, 22:42 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 17 Feb 2012, 18:16 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
                        1
                        • GianlucaG Offline
                          GianlucaG Offline
                          Gianluca
                          wrote on 16 Sept 2013, 20:42 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 Extensions
                          • Unsolved