Results 1 to 12 of 12

Thread: Reading an image with extension *.tif

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Reading an image with extension *.tif

    Hi guys,
    I'm working on zooming options and want to read an image with tif extension. When I use an image with extension jpeg it works fine. But the image is not displayed when I use a file with extension tif.

    Here is the sample code of constructor
    Qt Code:
    1. myWidget::myWidget( const char* imageFileName, QWidget *parent )
    2. : QWidget( parent )
    3. {
    4. m_pm = new QPixmap( imageFileName );
    5. factorZoom = 0.30001;
    6. setMinimumSize( m_pm->width()*factorZoom, m_pm->height(), factorZoom );
    7. }
    To copy to clipboard, switch view to plain text mode 
    When imageFileName is "test.jpeg" program works fine and the image is viewed and zoomed.
    When imageFileName is "test.tif", nothing is displayed.


    When I double clik on "tif" image from outside. It says "Drawing failed" in "Windows Picture and Fax Viewer on windows Xp".

    I can view the image using Irfan view. The properties of the image are as follows

    Dimensions: 1110 x 1118
    Type: TIF image
    Size: 2.39 MB

    How to display a "tif" image on a widget????

    Thanks

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by vermarajeev View Post
    How to display a "tif" image on a widget????
    If you check out the supported image formats in the Qt docs, you won't find tif. If it is not supported, you are on your own.

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by Kumosan View Post
    If you check out the supported image formats in the Qt docs, you won't find tif. If it is not supported, you are on your own.
    I know Qt doesnt support tif format but there has to be some workaround. I want to know how that is possible???

    And by the way what do you mean by "If it is not supported, you are on your own"

  4. #4
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by vermarajeev View Post

    And by the way what do you mean by "If it is not supported, you are on your own"
    You have to find your own solution.
    Use the qt 4.3 beta.
    Write your own tif plugin
    Use a third party lib, e.g. with imagemagick.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading an image with extension *.tif

    There is a TIFF plugin available - http://artis.imag.fr/Software/TiffIO/

  6. The following user says thank you to wysota for this useful post:

    vermarajeev (26th March 2007)

  7. #6
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by wysota View Post
    There is a TIFF plugin available - http://artis.imag.fr/Software/TiffIO/
    If wysota,
    I tried running the code provided, using the link. First I ran demo.pro to see how tiff images can be loaded. There was no tif option available. Then I ran test.pro as said in the document. I get this messages

    Qt Code:
    1. D:\TiffIo-1.30e\TiffIO-130e>test-debug.exe
    2. *** NO JPEG SUPPORT ***
    3. zip compression support
    4. lzw compression support
    5. packbits (aka rle) supported
    6. pixarlog supported
    7. Using temp dir = C:\DOCUME~1\rajeevv\LOCALS~1\Temp
    8. All images checked ok (50 reads, 95 write/rereads, 9 unsupported)
    To copy to clipboard, switch view to plain text mode 

    Why m I not getting tif after i run demo.pro.... How can I solve the above problem????

    Thanks

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading an image with extension *.tif

    Do you have libtiff? Did you install the plugin in the proper place?

    BTW. I saw that Qt (at least the 4.3 beta version) can build its own TIFF plugin, so you might try recompiling Qt as well. Remember that you need libtiff and its development files to compile the plugin.

  9. #8
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by wysota View Post
    Do you have libtiff? Did you install the plugin in the proper place?

    BTW. I saw that Qt (at least the 4.3 beta version) can build its own TIFF plugin, so you might try recompiling Qt as well. Remember that you need libtiff and its development files to compile the plugin.
    To solve the above problem I first tried to create my own plugin and see how it works.
    I just tried out something like this
    Qt Code:
    1. //plugin.h
    2. #include <qwidgetplugin.h>
    3.  
    4. class CustomWidgetPlugin : public QWidgetPlugin
    5. {
    6. public:
    7. CustomWidgetPlugin();
    8.  
    9. QStringList keys() const;
    10. QWidget* create( const QString &classname, QWidget* parent = 0, const char* name = 0 );
    11. QString group( const QString& ) const;
    12. QIconSet iconSet( const QString& ) const;
    13. QString includeFile( const QString& ) const;
    14. QString toolTip( const QString& ) const;
    15. QString whatsThis( const QString& ) const;
    16. bool isContainer( const QString& ) const;
    17. };
    To copy to clipboard, switch view to plain text mode 

    //plugin.cpp
    Qt Code:
    1. #include "plugin.h"
    2. #include "../fileChooser/filechooser.h"
    3.  
    4. static const char *filechooser_pixmap[] = {
    5. "22 22 8 1",
    6. " c Gray100",
    7. ". c Gray97",
    8. "X c #4f504f",
    9. "o c #00007f",
    10. "O c Gray0",
    11. "+ c none",
    12. "@ c Gray0",
    13. "# c Gray0",
    14. "++++++++++++++++++++++",
    15. "++++++++++++++++++++++",
    16. "++++++++++++++++++++++",
    17. "++++++++++++++++++++++",
    18. "+OOOOOOOOOOOOOOOOOOOO+",
    19. "OOXXXXXXXXXXXXXXXXXXOO",
    20. "OXX. OO OO O",
    21. "OX. oo O O",
    22. "OX. oo O .O",
    23. "OX ooo oooo O O",
    24. "OX oo oo oo O O",
    25. "OX oooo oo oo O O",
    26. "OX oo oo oo oo O O",
    27. "OX oo oo oo oo O O",
    28. "OX oooo oooo O O",
    29. "OX OO OO O",
    30. "OO..................OO",
    31. "+OOOOOOOOOOOOOOOOOOOO+",
    32. "++++++++++++++++++++++",
    33. "++++++++++++++++++++++",
    34. "++++++++++++++++++++++",
    35. "++++++++++++++++++++++"
    36. };
    37.  
    38. CustomWidgetPlugin::CustomWidgetPlugin()
    39. {
    40. }
    41.  
    42. QStringList CustomWidgetPlugin::keys() const
    43. {
    44. list << "FileChooser";
    45. return list;
    46. }
    47.  
    48. QWidget* CustomWidgetPlugin::create( const QString &key, QWidget* parent, const char* name )
    49. {
    50. if ( key == "FileChooser" )
    51. return new FileChooser( parent, name );
    52. return 0;
    53. }
    54.  
    55. QString CustomWidgetPlugin::group( const QString& feature ) const
    56. {
    57. if ( feature == "FileChooser" )
    58. return "Input";
    59. return QString::null;
    60. }
    61.  
    62. QIconSet CustomWidgetPlugin::iconSet( const QString& ) const
    63. {
    64. return QIconSet( QPixmap( filechooser_pixmap ) );
    65. }
    66.  
    67. QString CustomWidgetPlugin::includeFile( const QString& feature ) const
    68. {
    69. if ( feature == "FileChooser" )
    70. return "filechooser.h";
    71. return QString::null;
    72. }
    73.  
    74. QString CustomWidgetPlugin::toolTip( const QString& feature ) const
    75. {
    76. if ( feature == "FileChooser" )
    77. return "File Chooser Widget";
    78. return QString::null;
    79. }
    80.  
    81. QString CustomWidgetPlugin::whatsThis( const QString& feature ) const
    82. {
    83. if ( feature == "FileChooser" )
    84. return "A widget to choose a file or directory";
    85. return QString::null;
    86. }
    87.  
    88. bool CustomWidgetPlugin::isContainer( const QString& ) const
    89. {
    90. return FALSE;
    91. }
    92.  
    93.  
    94. Q_EXPORT_PLUGIN( CustomWidgetPlugin )
    To copy to clipboard, switch view to plain text mode 
    This is an example from Qt docs.
    Here is a sample program I have used
    Qt Code:
    1. //test.h
    2. #ifndef TEST_H
    3. #define TEST_H
    4.  
    5. #include <qwidget.h>
    6.  
    7. class testPlugin : public QWidget
    8. {
    9. public:
    10. testPlugin(QWidget* parent = 0, const char* name = 0);
    11. ~testPlugin(){}
    12. private:
    13. };
    14. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //TEST.CPP
    2. #include "test.h"
    3.  
    4.  
    5. testPlugin::testPlugin(QWidget* parent, const char* name)
    6. :QWidget(parent, name)
    7. {
    8. //what code to write to test the plugin.
    9. }
    To copy to clipboard, switch view to plain text mode 

    Now how do I make use of plugin defined above. I read "Creating Custom Widgets" provided by QtAssistance in qt3.3.5. Here is the link http://doc.trolltech.com/3.3/designer-manual-7.html
    I too searched qtcenter search but the answers are all related to qt4.

    Also how to install the plugin?

    Thanks

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading an image with extension *.tif

    But what does a widget plugin has to do with an imageformat plugin (apart from the "plugin" in the name)?

    The imageformat plugin has to be placed in $QTDIR/plugins/imageformats.

  11. #10
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by wysota View Post
    But what does a widget plugin has to do with an imageformat plugin (apart from the "plugin" in the name)?

    The imageformat plugin has to be placed in $QTDIR/plugins/imageformats.
    Hi wysota,
    Thanks for you reply.

    Before using plugin I should know how I can use it. So I have a sample program to see how plugin works.

    This path $QTDIR/plugins/imageformats helped to fix my first problem. Thanks once more.
    Last edited by vermarajeev; 26th March 2007 at 10:34.

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading an image with extension *.tif

    Please don't mix two completely different problems in the same forum thread.

  13. #12
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading an image with extension *.tif

    Quote Originally Posted by wysota View Post
    Please don't mix two completely different problems in the same forum thread.
    Sorry, I have edited and made the corrections.

Similar Threads

  1. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  2. Fast image drawing/scaling in Qt 3.3
    By eriwik in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 10:45
  3. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  4. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01
  5. reading in image from 24bit char*
    By cbeall1 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2006, 00:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.