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. How to Customize QTiffHandler
Forum Updated to NodeBB v4.3 + New Features

How to Customize QTiffHandler

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 467 Views 2 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.
  • R Offline
    R Offline
    Rory_1
    wrote on 13 Aug 2019, 16:19 last edited by
    #1

    My application makes use of image thumbnails to improve performance. Tiff files can contain multiple images in subfiles or directories. QTiffHandler reads the first directory, but I want to scan all available directories and choose which one to read. Is there a way for me to "subclass" QTiffHandler? If not, I could create my own routines to read a tiff directory into a QImage. If I take that approach can I access the libtiff source in the Qt distribution safely, or do I need to independently keep it in my project?

    Any recommendations on the best approach and suggested reading material is greatly appreciated.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 Aug 2019, 16:45 last edited by
      #2

      Hi
      First, i would look at the source.
      https://code.woboq.org/qt5/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp.html#852
      It seems to have support for Tiff Directories.

      bool QTiffHandler::jumpToNextImage()
      bool QTiffHandler::jumpToImage(int imageNumber)
      int QTiffHandler::imageCount() const
      int QTiffHandler::currentImageNumber() const
      

      However, its unclear to me if those are avialable to use from App.

      Since its being a plugin, i would check if i could upgrade the existing code to support the feature needed and
      simply use this new plugin instead of the old. After all that is the benefit with plugins.
      However, the image plugins might not offer easy way to use these new features as its
      used by Qt internally and might not be super easy to surface. However its worth checking out
      before starting to use the lib directly. IMHO.

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Rory_1
        wrote on 13 Aug 2019, 17:05 last edited by
        #3

        @mrjj Thanks for the response! I see that QImageReader supports jumpToNextImage. I'll see if that works. I already have code that walks the tiff IFDs so I know in advance which directory I want to use. If this works then I will mark the topic as solved, although I really would like to know how to customize QTiffHandler ;*)

        M 1 Reply Last reply 13 Aug 2019, 17:16
        0
        • R Rory_1
          13 Aug 2019, 17:05

          @mrjj Thanks for the response! I see that QImageReader supports jumpToNextImage. I'll see if that works. I already have code that walks the tiff IFDs so I know in advance which directory I want to use. If this works then I will mark the topic as solved, although I really would like to know how to customize QTiffHandler ;*)

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 Aug 2019, 17:16 last edited by
          #4

          @rory_1

          • although I really would like to know how to customize QTiffHandler ;*)
            As far as i know, the best option would be to change the plugin and "subclass"
            by using the new plugin instead.
          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rory_1
            wrote on 13 Aug 2019, 17:32 last edited by
            #5

            Unfortunately QImageReader::imageCount() is returning 1 for a tiff file with 4 directories (created in photoshop with save image pyramid), so this approach does not appear to be workable. It might be a failure of libtiff since QTiffHandler does have an imageCount function.

            M 1 Reply Last reply 13 Aug 2019, 17:40
            0
            • R Rory_1
              13 Aug 2019, 17:32

              Unfortunately QImageReader::imageCount() is returning 1 for a tiff file with 4 directories (created in photoshop with save image pyramid), so this approach does not appear to be workable. It might be a failure of libtiff since QTiffHandler does have an imageCount function.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 13 Aug 2019, 17:40 last edited by
              #6

              @rory_1
              Ok, good digging
              it seems it does call the handlers function so i agree it might be related to the libTiff

              int QImageReader::imageCount() const
              {
                  if (!d->initHandler())
                      return -1;
                  return d->handler->imageCount();
              }
              
              

              However, reading the docs, it seems that function is for animation support so
              im not sure its what we want even the actual code seems to be related to TIFF dirs.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rory_1
                wrote on 13 Aug 2019, 18:19 last edited by
                #7

                @mrjj

                I'm going to try implementing libtiff in my own project. Can I use the libtiff source included with Qt? If so what is the suggested way of supplying the path in the includes. The folder is at C:\Qt\5.13.0\Src\qtimageformats\src\3rdparty\libtiff\libtiff on my windows machine.

                R 1 Reply Last reply 14 Aug 2019, 16:38
                0
                • R Rory_1
                  13 Aug 2019, 18:19

                  @mrjj

                  I'm going to try implementing libtiff in my own project. Can I use the libtiff source included with Qt? If so what is the suggested way of supplying the path in the includes. The folder is at C:\Qt\5.13.0\Src\qtimageformats\src\3rdparty\libtiff\libtiff on my windows machine.

                  R Offline
                  R Offline
                  Rory_1
                  wrote on 14 Aug 2019, 16:38 last edited by
                  #8

                  I'm going to mark this as solved as I have found a work-around iterating the photoshop IRB in a TIFF to find an embedded thumbnail.

                  1 Reply Last reply
                  1

                  1/8

                  13 Aug 2019, 16:19

                  • Login

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