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
Code:
myWidget
::myWidget( const char* imageFileName,
QWidget *parent
) {
m_pm
= new QPixmap( imageFileName
);
factorZoom = 0.30001;
setMinimumSize( m_pm->width()*factorZoom, m_pm->height(), factorZoom );
}
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
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
vermarajeev
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.
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
Kumosan
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"
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
vermarajeev
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.
Re: Reading an image with extension *.tif
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
wysota
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
Code:
D:\TiffIo-1.30e\TiffIO-130e>test-debug.exe
*** NO JPEG SUPPORT ***
zip compression support
lzw compression support
packbits (aka rle) supported
pixarlog supported
Using temp dir = C:\DOCUME~1\rajeevv\LOCALS~1\Temp
All images checked ok (50 reads, 95 write/rereads, 9 unsupported)
Why m I not getting tif after i run demo.pro.... How can I solve the above problem????
Thanks
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.
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
wysota
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
Code:
//plugin.h
#include <qwidgetplugin.h>
class CustomWidgetPlugin : public QWidgetPlugin
{
public:
CustomWidgetPlugin();
QString group
( const QString
& ) const;
QIconSet iconSet( const QString& ) const;
QString includeFile
( const QString
& ) const;
QString toolTip
( const QString
& ) const;
QString whatsThis
( const QString
& ) const;
bool isContainer( const QString& ) const;
};
//plugin.cpp
Code:
#include "plugin.h"
#include "../fileChooser/filechooser.h"
static const char *filechooser_pixmap[] = {
"22 22 8 1",
" c Gray100",
". c Gray97",
"X c #4f504f",
"o c #00007f",
"O c Gray0",
"+ c none",
"@ c Gray0",
"# c Gray0",
"++++++++++++++++++++++",
"++++++++++++++++++++++",
"++++++++++++++++++++++",
"++++++++++++++++++++++",
"+OOOOOOOOOOOOOOOOOOOO+",
"OOXXXXXXXXXXXXXXXXXXOO",
"OXX. OO OO O",
"OX. oo O O",
"OX. oo O .O",
"OX ooo oooo O O",
"OX oo oo oo O O",
"OX oooo oo oo O O",
"OX oo oo oo oo O O",
"OX oo oo oo oo O O",
"OX oooo oooo O O",
"OX OO OO O",
"OO..................OO",
"+OOOOOOOOOOOOOOOOOOOO+",
"++++++++++++++++++++++",
"++++++++++++++++++++++",
"++++++++++++++++++++++",
"++++++++++++++++++++++"
};
CustomWidgetPlugin::CustomWidgetPlugin()
{
}
{
list << "FileChooser";
return list;
}
{
if ( key == "FileChooser" )
return new FileChooser( parent, name );
return 0;
}
QString CustomWidgetPlugin
::group( const QString
& feature
) const {
if ( feature == "FileChooser" )
return "Input";
}
QIconSet CustomWidgetPlugin::iconSet( const QString& ) const
{
return QIconSet
( QPixmap( filechooser_pixmap
) );
}
QString CustomWidgetPlugin
::includeFile( const QString
& feature
) const {
if ( feature == "FileChooser" )
return "filechooser.h";
}
QString CustomWidgetPlugin
::toolTip( const QString
& feature
) const {
if ( feature == "FileChooser" )
return "File Chooser Widget";
}
QString CustomWidgetPlugin
::whatsThis( const QString
& feature
) const {
if ( feature == "FileChooser" )
return "A widget to choose a file or directory";
}
bool CustomWidgetPlugin::isContainer( const QString& ) const
{
return FALSE;
}
Q_EXPORT_PLUGIN( CustomWidgetPlugin )
This is an example from Qt docs.
Here is a sample program I have used
Code:
//test.h
#ifndef TEST_H
#define TEST_H
#include <qwidget.h>
{
public:
testPlugin
(QWidget* parent
= 0,
const char* name
= 0);
~testPlugin(){}
private:
};
#endif
Code:
//TEST.CPP
#include "test.h"
testPlugin
::testPlugin(QWidget* parent,
const char* name
){
//what code to write to test the plugin.
}
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
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.
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
wysota
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.
Re: Reading an image with extension *.tif
Please don't mix two completely different problems in the same forum thread.
Re: Reading an image with extension *.tif
Quote:
Originally Posted by
wysota
Please don't mix two completely different problems in the same forum thread.
Sorry, I have edited and made the corrections. :rolleyes: