Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Types | Private Attributes
icl::qt::QImageConverter Class Reference

class for conversion between QImage and core::ImgBase/Img<T> More...

#include <QImageConverter.h>

List of all members.

Public Member Functions

 QImageConverter ()
 creates an empty QImageConverter object
 QImageConverter (const core::ImgBase *image)
 creates a QImageConverter object with given ImgBase
 QImageConverter (const QImage *qimage)
 creates a QImageConverter object with given QImage
 ~QImageConverter ()
 Destructor.
const QImage * getQImage ()
 returns a converted QImage
const core::ImgBasegetImgBase (core::depth d=core::depth8u)
 returns converted core::ImgBase (of given core::depth")
template<class T >
const core::Img< T > * getImg ()
 template returing an image of given datatype
void setImage (const core::ImgBase *image)
 sets the current source image of type core::Img8u or Img32f
void setQImage (const QImage *qimage)
 sets the current source image of type QImage
void setUseSpeudoColors (bool use)
 sets whether to use speudo colors for grayscale image (default is false)

Private Types

enum  State { given = 0, uptodate = 1, undefined = 2 }
 internal used state struct More...

Private Attributes

core::ImgBasem_apoBuf [5]
 internal buffer for Imgs of all depths
QImage * m_poQBuf
 internal qimage buffer
State m_aeStates [5]
 internal state buffer (states indicate if images are uptodate, given or outdated
State m_eQImageState
 internal state buffer for the QImage buffer
bool m_usePC
 use pseudo colors

Detailed Description

class for conversion between QImage and core::ImgBase/Img<T>

The QImageConverter class provides functionality for conversion between the QImage class and the core::Img<T> classes. It provides an internal buffer handling for the destination images, so that the user does not have to care about memory handling. The user must only take care, that the given image is persistent.

Use cases

The basic use case is just to convert one Image into another:

       
        core::ImgBase *i = imgNew(...);
        QImage *q = QImageConverter(i).getImage();
        

This will temporarily create a converter object on the stack, that converts the given image i into a qimage. The opposite direction (QImage to core::ImgBase) behaves identically. Note: that the converted image is only persistent as long as the QImageConverter object is.

Another use-case is to optimize performance in a working loop, by reusing the same instance of QImageConverter. By writing

        QImageConverter c;
        while(true){
           ...
           core::ImgBase *i = ...
           c.setImage(i);
           QImage *q = q.getQImage();
           ...
        }
        

The converter will internally adapt itself to this use-case (getting pointers to core::ImgBase objects and returning pointers to QImages) that no memory allocation must be performed during the iteration. Only if several use cases are performed alternating, it might be necessary to allocate and release memory during lifetime.

Note: If you call setImage(core::Img8u* xxx) before calling getImage8u() you will get a copy of the pointer xxx. This is essentially, as you will not have a 2nd instance of the image.


Member Enumeration Documentation

internal used state struct

Enumerator:
given 

this image was given calling setImage

uptodate 

this image has already been converted

undefined 

this image is not defined or outdated


Constructor & Destructor Documentation

creates an empty QImageConverter object

creates a QImageConverter object with given ImgBase

icl::qt::QImageConverter::QImageConverter ( const QImage *  qimage)

creates a QImageConverter object with given QImage

Destructor.

if the released object was the last QImageConverter object, all static buffers are freed, to avoid large unused memory


Member Function Documentation

template<class T >
const core::Img<T>* icl::qt::QImageConverter::getImg ( )

template returing an image of given datatype

returns converted core::ImgBase (of given core::depth")

This function will cause an error if no images were set before. Images can be set by calling setImage, setQImage, or by using one of the not empty constructors.

returns a converted QImage

This function will cause an error if no images were set before. Images can be set by calling setImage, setQImage, or by using one of the not empty constructors.

sets the current source image of type core::Img8u or Img32f

All further set images get the state "outdated". Hence all later getImg[Base]-calls must perform a deep conversion first

void icl::qt::QImageConverter::setQImage ( const QImage *  qimage)

sets the current source image of type QImage

All further set images get the state "outdated". Hence all later getImg[Base]-calls must perform a deep conversion first

sets whether to use speudo colors for grayscale image (default is false)

Right now, speudo colors are only used for Img to QImage conversion and for single channel input images


Member Data Documentation

internal state buffer (states indicate if images are uptodate, given or outdated

internal buffer for Imgs of all depths

internal state buffer for the QImage buffer

internal qimage buffer

use pseudo colors


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines