Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changing size of image
Forum Updated to NodeBB v4.3 + New Features

Changing size of image

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.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.
  • G Offline
    G Offline
    grizz
    wrote on last edited by
    #1

    Hi. I want to load .bmp file to QImage, add some pixels and change QImage's size. QImage is part o a class, eg.:

    @
    #include <QGraphicsView>
    #include <QImage>

    class obraz : public QGraphicsView
    {
    Q_OBJECT
    public:
    explicit obraz(QWidget *parent = 0);
    QImage image;
    };
    @

    How to change QImage size?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      You mean like "scaling":http://developer.qt.nokia.com/doc/qt-4.8/qimage.html#scaled an image ?

      @
      Image.scaled(Size, Qt::KeepAspectRatio);
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        grizz
        wrote on last edited by
        #3

        Doesn't work. And how to load another QImage to QImage?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          [quote author="grizz" date="1328524306"]Doesn't work. [/quote]

          Did you observe that scaled returns the scaled QImage?
          It is not listed in "the in-place section":http://developer.qt.nokia.com/doc/qt-4.8/qimage.html#image-transformations

          [quote author="grizz" date="1328524306"]And how to load another QImage to QImage?[/quote]

          Did you try ?:
          @
          Image = Image.scaled(Size, Qt::KeepAspectRatio);
          @

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            grizz
            wrote on last edited by
            #5

            Now it works. I tried something like that earlier and it didn't work, but now I know what I made wrong. Thank you.

            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