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 691 Views 3 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.
  • ademmlerA Offline
    ademmlerA Offline
    ademmler
    wrote on 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

    Pl45m4P 1 Reply Last reply
    0
    • ademmlerA Offline
      ademmlerA Offline
      ademmler
      wrote on 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
      • ademmlerA ademmler

        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

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on 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
        • ademmlerA Offline
          ademmlerA Offline
          ademmler
          wrote on 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
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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

            ademmlerA 1 Reply Last reply
            1
            • SGaistS SGaist

              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.

              ademmlerA Offline
              ademmlerA Offline
              ademmler
              wrote on last edited by
              #5

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

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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
                • ademmlerA Offline
                  ademmlerA Offline
                  ademmler
                  wrote on last edited by
                  #7

                  @SGaist thx for the hint.

                  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