Image Component Library (ICL)
|
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::ImgBase * | getImgBase (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::ImgBase * | m_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... | |
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.
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.
|
private |
icl::qt::QImageConverter::QImageConverter | ( | ) |
creates an empty QImageConverter object
icl::qt::QImageConverter::QImageConverter | ( | const core::ImgBase * | image | ) |
creates a QImageConverter object with given ImgBase
icl::qt::QImageConverter::QImageConverter | ( | const QImage * | qimage | ) |
creates a QImageConverter object with given QImage
icl::qt::QImageConverter::~QImageConverter | ( | ) |
Destructor.
if the released object was the last QImageConverter object, all static buffers are freed, to avoid large unused memory
const core::Img<T>* icl::qt::QImageConverter::getImg | ( | ) |
template returing an image of given datatype
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.
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.
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
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
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
|
private |
internal state buffer (states indicate if images are uptodate, given or outdated
|
private |
internal buffer for Imgs of all depths
|
private |
internal state buffer for the QImage buffer
|
private |
internal qimage buffer
|
private |
use pseudo colors