Image Component Library (ICL)
Public Member Functions | Private Types | Private Attributes | List of all members
icl::qt::QImageConverter Class Reference

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

#include <QImageConverter.h>

Public Member Functions

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

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 More...
 
QImage * m_poQBuf
 internal qimage buffer More...
 
State m_aeStates [5]
 internal state buffer (states indicate if images are uptodate, given or outdated More...
 
State m_eQImageState
 internal state buffer for the QImage buffer More...
 
bool m_usePC
 use pseudo colors More...
 

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

◆ State

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

◆ QImageConverter() [1/3]

icl::qt::QImageConverter::QImageConverter ( )

creates an empty QImageConverter object

◆ QImageConverter() [2/3]

icl::qt::QImageConverter::QImageConverter ( const core::ImgBase image)

creates a QImageConverter object with given ImgBase

◆ QImageConverter() [3/3]

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

creates a QImageConverter object with given QImage

◆ ~QImageConverter()

icl::qt::QImageConverter::~QImageConverter ( )

Destructor.

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

Member Function Documentation

◆ getImg()

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

template returing an image of given datatype

◆ getImgBase()

const core::ImgBase* icl::qt::QImageConverter::getImgBase ( core::depth  d = core::depth8u)

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.

◆ getQImage()

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

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.

◆ setImage()

void icl::qt::QImageConverter::setImage ( const core::ImgBase image)

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

◆ setQImage()

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

◆ setUseSpeudoColors()

void icl::qt::QImageConverter::setUseSpeudoColors ( bool  use)

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

◆ m_aeStates

State icl::qt::QImageConverter::m_aeStates[5]
private

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

◆ m_apoBuf

core::ImgBase* icl::qt::QImageConverter::m_apoBuf[5]
private

internal buffer for Imgs of all depths

◆ m_eQImageState

State icl::qt::QImageConverter::m_eQImageState
private

internal state buffer for the QImage buffer

◆ m_poQBuf

QImage* icl::qt::QImageConverter::m_poQBuf
private

internal qimage buffer

◆ m_usePC

bool icl::qt::QImageConverter::m_usePC
private

use pseudo colors


The documentation for this class was generated from the following file: