but you didn't say it had to be using Qt, and based on your detailed list of features what you have outlined is a major piece of work. You also didn't say what your application was, so I suggested something that might work out of the box for you.I am a true beginner in Qt ... So I would like to create a simple image viewer
But if you really want to write it yourself...
QImage and QPixmap are the two primary Qt classes for image manipulation and display. QPixmap is optimized for display on screen, QImage is optimized for I/O and manipulation. Support for some image file formats (like tiff) require an external Qt plugin (DLL) that must be loaded at runtime. QImage uses a copy-on-write model for its data, so if you pass a pointer to an external buffer when creating a QImage, the data will not be copied. The external buffer has to remain valid for the life of the QImage. QPixmap also uses data sharing.a) with good speed performance and memory usage (in case of big images)
b) reading only gray-scale tiff image, but with different possible pixel depth (8, 16 or 32 bits)
c) with basic mouse interactivity (pan/scan/read pixel position and value)
I would guess that the tiff reader would be able to create a QImage of whatever bit depth is represented in the file.
The usual way to display an image is to convert it to a QPixmap and install it on a QLabel in a normal QWidget-based UI, or to create a QGraphicsScene with a QGraphicsPixmapItem containing the QPixmap. If you want to interactively places labels or other annotations on a displayed image, I would recommend using the QGraphicsScene approach. Annotations could be added in a reversible manner by adding them as independent QGraphicsItem instances in the scene.
Mouse interactivity (pan / zoom, etc.) can be achieved by using a QScrollArea and QLabel and manipulating the viewport (region of the image that is displayed in the window), or by using the QGraphicsScene / QGraphicsView and manipulating the view's sceneRect().
Retrieving pixel values can only be done using a QImage. A QPixmap is basically a write-only output device. Mouse events on either a QLabel or QGraphicsPixmapItem will tell you the screen or window coordinates of the mouse location, which you would have to map to the image location to be able to retrieve the pixel value. This would of course be affected by any pan or zoom transformation you have applied to the image. QPixmap will interpolate pixel values when scaling an image, so there may not be a 1:1 correspondence between the screen pixel coordinates and pixel coordinates in the source image.




Reply With Quote
Bookmarks