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. VIPS image skewed in QT

VIPS image skewed in QT

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 448 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.
  • A Offline
    A Offline
    ademmler
    wrote on 29 Jul 2020, 09:39 last edited by
    #1

    I am trying to load an image with lib vips and display this in Qt.
    After loading the image and passing it to QImage - the image is skewed.

    Below you can download a minimal code sample and a test image.
    Also two screenshots from using vips or qt internal function to load image.

    Any hint and help is welcome.
    thx in advance Alexander

    http://files.lacunasolutions.com/various/VipsMinimal.zip

    P 1 Reply Last reply 29 Jul 2020, 10:27
    0
    • A Offline
      A Offline
      ademmler
      wrote on 29 Jul 2020, 14:00 last edited by
      #3

      I got help from VIPS maintainer. Here is what did the trick ...

      /*
      * Hint from vips guy for fixinf skewing:
      * In your code, you are using QImage(pointer, width, height, format).
      * Perhaps this has assumptions about scanline padding?
      * I would try the constructor that lets you set bytesperline as well.
      * Use VIPS_IMAGE_SIZEOF_LINE(image.get_image()) to get the line size.
      */

         vipsObject = VImage::new_from_file (imagePath.toStdString().c_str(), VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL));
      
         imageObject = new QImage();
         *imageObject = QImage((uchar*)vipsObject.data(), vipsObject.width(), vipsObject.height(), VIPS_IMAGE_SIZEOF_LINE(vipsObject.get_image()), QImage::Format_RGB888);
         image = QPixmap::fromImage(*imageObject);
      
      1 Reply Last reply
      1
      • A ademmler
        29 Jul 2020, 09:39

        I am trying to load an image with lib vips and display this in Qt.
        After loading the image and passing it to QImage - the image is skewed.

        Below you can download a minimal code sample and a test image.
        Also two screenshots from using vips or qt internal function to load image.

        Any hint and help is welcome.
        thx in advance Alexander

        http://files.lacunasolutions.com/various/VipsMinimal.zip

        P Online
        P Online
        Pl45m4
        wrote on 29 Jul 2020, 10:27 last edited by
        #2

        @ademmler

        This looks like an image-type issue. I'm not an expert, when it comes to VIPS (more experience with OCV). but what channel structure do these vip-images have? Is there an alpha channel?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        1
        • A Offline
          A Offline
          ademmler
          wrote on 29 Jul 2020, 14:00 last edited by
          #3

          I got help from VIPS maintainer. Here is what did the trick ...

          /*
          * Hint from vips guy for fixinf skewing:
          * In your code, you are using QImage(pointer, width, height, format).
          * Perhaps this has assumptions about scanline padding?
          * I would try the constructor that lets you set bytesperline as well.
          * Use VIPS_IMAGE_SIZEOF_LINE(image.get_image()) to get the line size.
          */

             vipsObject = VImage::new_from_file (imagePath.toStdString().c_str(), VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL));
          
             imageObject = new QImage();
             *imageObject = QImage((uchar*)vipsObject.data(), vipsObject.width(), vipsObject.height(), VIPS_IMAGE_SIZEOF_LINE(vipsObject.get_image()), QImage::Format_RGB888);
             image = QPixmap::fromImage(*imageObject);
          
          1 Reply Last reply
          1
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 Jul 2020, 18:16 last edited by
            #4

            Hi,

            One important thing: there's no need for imageObject to be allocated on the heap. You are likely leaking it with the way you use your code.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply 29 Jul 2020, 18:50
            1
            • S SGaist
              29 Jul 2020, 18:16

              Hi,

              One important thing: there's no need for imageObject to be allocated on the heap. You are likely leaking it with the way you use your code.

              A Offline
              A Offline
              ademmler
              wrote on 29 Jul 2020, 18:50 last edited by
              #5

              @SGaist What does this mean in detail?
              What should I change?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 29 Jul 2020, 20:21 last edited by
                #6

                @ademmler said in VIPS image skewed in QT:

                imageObject

                Make it a simple QImage. No pointers needed.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ademmler
                  wrote on 30 Jul 2020, 08:15 last edited by
                  #7

                  @SGaist thx for the hint.

                  1 Reply Last reply
                  0

                  3/7

                  29 Jul 2020, 14:00

                  • Login

                  • Login or register to search.
                  3 out of 7
                  • First post
                    3/7
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved