QuOc

 

Public Member Functions | Protected Attributes

qc::ConcatImage< DataType, RealType > Class Template Reference

#include <imageTools.h>

Inheritance diagram for qc::ConcatImage< DataType, RealType >:
ScalarArray

List of all members.

Public Member Functions

 ConcatImage (ScalarArray< DataType, qc::QC_2D > &image1, ScalarArray< DataType, qc::QC_2D > &image2, const ConcatType type=LEFT_RIGHT, const int spacing=1, const unsigned char bgColor=255)
virtual bool createOverflowHandeledData (unsigned char *tmp, DataType *min=NULL, DataType *max=NULL) const

Protected Attributes

const ScalarArray< DataType,
qc::QC_2D > & 
_image1
const ScalarArray< DataType,
qc::QC_2D > & 
_image2
const ConcatType _type
const int _spacing
const unsigned char _bgColor

Detailed Description

template<typename DataType, typename RealType = float>
class qc::ConcatImage< DataType, RealType >

Class that allows the concatenation of ScalarArray<QC_2D>-objects for the purpose of output as a PGM image. It the ScalarArrays are of different sizes the images will be aligned top and right in the output image. Any background will be filled with the specified color. Please note that the recursive use of ConcatImage is possible. I.e. you can concatenate ConcatImages with this class as well. Please note further that this class is meaningful only for output as PGM image. In fact to save memory the implementation does some nasty things in terms of memory management.

Definition at line 37 of file imageTools.h.


Constructor & Destructor Documentation

template<typename DataType , typename RealType = float>
qc::ConcatImage< DataType, RealType >::ConcatImage ( ScalarArray< DataType, qc::QC_2D > &  image1,
ScalarArray< DataType, qc::QC_2D > &  image2,
const ConcatType  type = LEFT_RIGHT,
const int  spacing = 1,
const unsigned char  bgColor = 255 
) [inline]

Definition at line 44 of file imageTools.h.

References qc::LEFT_RIGHT, aol::Max(), and qc::TOP_BOTTOM.

                                                                           :
      ScalarArray<DataType, qc::QC_2D> ( 1, 1 ),
      _image1 ( image1 ), _image2 ( image2 ), _type ( type ), _spacing ( spacing ), _bgColor ( bgColor ) {
    switch ( type ) {
    case LEFT_RIGHT :
      this->numX = image1.getNumX() + spacing + image2.getNumX();
      this->numY = aol::Max ( image1.getNumY(), image2.getNumY() );
      break;
    case TOP_BOTTOM:
      this->numX = aol::Max ( image1.getNumX(), image2.getNumX() );
      this->numY = image1.getNumY() + spacing + image2.getNumY();
      break;
    }
  }


Member Function Documentation

template<typename DataType , typename RealType = float>
virtual bool qc::ConcatImage< DataType, RealType >::createOverflowHandeledData ( unsigned char tmp,
DataType min = NULL,
DataType max = NULL 
) const [inline, virtual]

Definition at line 62 of file imageTools.h.

References qc::ConcatImage< DataType, RealType >::_bgColor, qc::ConcatImage< DataType, RealType >::_image1, qc::ConcatImage< DataType, RealType >::_image2, qc::ConcatImage< DataType, RealType >::_spacing, qc::ConcatImage< DataType, RealType >::_type, qc::LEFT_RIGHT, aol::Max(), aol::Min(), and qc::TOP_BOTTOM.

                                                                                                                   {
    const int w1 = _image1.getNumX();
    const int w2 = _image2.getNumX();
    const int h1 = _image1.getNumY();
    const int h2 = _image2.getNumY();

    const int w = this->getNumX();
    const int h = this->getNumY();

    typedef unsigned char UCHAR;

    UCHAR *img1 = new UCHAR[w1*h1];
    UCHAR *img2 = new UCHAR[w2*h2];

    _image1.createOverflowHandeledData ( img1, NULL, NULL );
    _image2.createOverflowHandeledData ( img2, NULL, NULL );

    memset ( tmp, _bgColor, w*h );

    int x, y;

    switch ( _type ) {
    case LEFT_RIGHT: {
      UCHAR *ptr = tmp, *ptr1 = img1, *ptr2 = img2;
      const int c = aol::Min ( h1, h2 );
      const int d = aol::Max ( h1, h2 );
      for ( y = 0; y < c; ++y ) {
        for ( x = 0; x < w1; ++x ) *ptr++ = *ptr1++;
        ptr += _spacing;
        for ( x = 0; x < w2; ++x ) *ptr++ = *ptr2++;
      }
      if ( c == d ) break;
      if ( c == h1 ) {
        for ( y = c; y < d; ++y ) {
          ptr += ( w1 + _spacing );
          for ( x = 0; x < w2; ++x ) *ptr++ = *ptr2++;
        }
      } else {
        for ( y = c; y < d; ++y ) {
          for ( x = 0; x < w1; ++x ) *ptr++ = *ptr1++;
          ptr += ( w2 + _spacing );
        }
      }
    }
    break;
    case TOP_BOTTOM: {
      UCHAR *ptr = tmp, *ptr1 = img1, *ptr2 = img2;
      const int c = w - w1;
      const int d = w - w2;
      for ( y = 0; y < h1; ++y ) {
        for ( x = 0; x < w1; ++x ) *ptr++ = *ptr1++;
        ptr += c;
      }
      ptr += ( _spacing * w );
      for ( y = 0; y < h2; ++y ) {
        for ( x = 0; x < w2; ++x ) *ptr++ = *ptr2++;
        ptr += d;
      }
    }
    break;
    };

    delete[] img1;
    delete[] img2;

    return false;
  }


Member Data Documentation

template<typename DataType , typename RealType = float>
const unsigned char qc::ConcatImage< DataType, RealType >::_bgColor [protected]
template<typename DataType , typename RealType = float>
const ScalarArray<DataType, qc::QC_2D>& qc::ConcatImage< DataType, RealType >::_image1 [protected]
template<typename DataType , typename RealType = float>
const ScalarArray<DataType, qc::QC_2D> & qc::ConcatImage< DataType, RealType >::_image2 [protected]
template<typename DataType , typename RealType = float>
const int qc::ConcatImage< DataType, RealType >::_spacing [protected]
template<typename DataType , typename RealType = float>
const ConcatType qc::ConcatImage< DataType, RealType >::_type [protected]

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

Generated on Fri Sep 9 2011 21:09:50 for QuocMesh by doxygen 1.7.1