App
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
app::TNearestFInt< TPIXEL, TCHANNEL > Class Template Reference

#include <TNearestFInt.hpp>

Inheritance diagram for app::TNearestFInt< TPIXEL, TCHANNEL >:
app::TFInterpolator< TPIXEL, TCHANNEL >

Public Member Functions

 TNearestFInt (const TBitmap< TPIXEL, TCHANNEL > &over)
 
virtual TPIXEL * getSrcData () const
 
virtual unsigned getSrcWidth () const
 
virtual unsigned getSrcHeight () const
 
virtual ~TNearestFInt ()
 
virtual int isInitOk () const
 
TPIXEL getAt (double x, double y)
 
virtual int resampleTo (TBitmap< TPIXEL, TCHANNEL > &dst) const
 
virtual int resampleTo_aliased (TBitmap< TPIXEL, TCHANNEL > &dst, double force=1) const
 

Static Public Attributes

static const unsigned chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
 
static const TCHANNEL maxVal = ~0
 

Protected Member Functions

virtual int resampleTo_4ch (TBitmap< TPIXEL, TCHANNEL > &dst) const
 
virtual int resampleTo_1ch (TBitmap< TPIXEL, TCHANNEL > &dst) const
 
virtual TFInterpolator< TPIXEL,
TCHANNEL > * 
newInstance (const TBitmap< TPIXEL, TCHANNEL > &over) const
 

Protected Attributes

TPIXEL * srcData
 
unsigned srcWidth
 
unsigned srcHeight
 

Detailed Description

template<typename TPIXEL, typename TCHANNEL>
class app::TNearestFInt< TPIXEL, TCHANNEL >

Definition at line 22 of file TNearestFInt.hpp.

Constructor & Destructor Documentation

template<typename TPIXEL, typename TCHANNEL>
app::TNearestFInt< TPIXEL, TCHANNEL >::TNearestFInt ( const TBitmap< TPIXEL, TCHANNEL > &  over)
inline

Definition at line 41 of file TNearestFInt.hpp.

{
srcData = over.getData();
srcWidth = over.getWidth();
srcHeight = over.getHeight();
}
template<typename TPIXEL , typename TCHANNEL >
TNearestFInt< TPIXEL, TCHANNEL >::~TNearestFInt ( )
virtual

Definition at line 14 of file TNearestFInt.cpp.

{
}

Member Function Documentation

template<typename TPIXEL, typename TCHANNEL>
TPIXEL app::TNearestFInt< TPIXEL, TCHANNEL >::getAt ( double  x,
double  y 
)
inline

Definition at line 64 of file TNearestFInt.hpp.

{
if (x >= 0 && y >= 0 && x < srcWidth && y < srcHeight) {
return srcData[((int)y) * srcWidth + (int)x];
} else {
return 0;
}
}
template<typename TPIXEL, typename TCHANNEL>
virtual TPIXEL* app::TNearestFInt< TPIXEL, TCHANNEL >::getSrcData ( ) const
inlinevirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 47 of file TNearestFInt.hpp.

{
return srcData;
}
template<typename TPIXEL, typename TCHANNEL>
virtual unsigned app::TNearestFInt< TPIXEL, TCHANNEL >::getSrcHeight ( ) const
inlinevirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 54 of file TNearestFInt.hpp.

{
return srcHeight;
}
template<typename TPIXEL, typename TCHANNEL>
virtual unsigned app::TNearestFInt< TPIXEL, TCHANNEL >::getSrcWidth ( ) const
inlinevirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 51 of file TNearestFInt.hpp.

{
return srcWidth;
}
template<typename TPIXEL, typename TCHANNEL>
virtual int app::TNearestFInt< TPIXEL, TCHANNEL >::isInitOk ( ) const
inlinevirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 60 of file TNearestFInt.hpp.

{
return 1;
}
template<typename TPIXEL, typename TCHANNEL>
virtual TFInterpolator<TPIXEL, TCHANNEL>* app::TNearestFInt< TPIXEL, TCHANNEL >::newInstance ( const TBitmap< TPIXEL, TCHANNEL > &  over) const
inlineprotectedvirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 32 of file TNearestFInt.hpp.

{
}
template<typename TPIXEL , typename TCHANNEL >
int TFInterpolator< TPIXEL, TCHANNEL >::resampleTo ( TBitmap< TPIXEL, TCHANNEL > &  dst) const
virtualinherited

Definition at line 13 of file TFInterpolator.cpp.

{
if (chCount == 1) {
return resampleTo_1ch(dst);
} else if (chCount == 4) {
return resampleTo_4ch(dst);
} else {
return 100;
}
}
template<typename TPIXEL , typename TCHANNEL >
int TNearestFInt< TPIXEL, TCHANNEL >::resampleTo_1ch ( TBitmap< TPIXEL, TCHANNEL > &  dst) const
protectedvirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 23 of file TNearestFInt.cpp.

{
TPIXEL * sPtr;
if (srcData == NULL) {
return 2;
}
unsigned dstWidth = dst.getWidth();
unsigned dstHeight = dst.getHeight();
TPIXEL * dstData = dst.getData();
if (dstData == NULL) {
return 3;
}
TPIXEL * dPtr = (TPIXEL *) dstData;
TPIXEL * dPtrRowEnd = (TPIXEL *) (dstData + dstWidth);
TPIXEL * dPtrEnd = (TPIXEL *) (dstData + dstWidth * dstHeight);
double dx = srcWidth / (double) dstWidth;
double x0 = dx / 2.0;
double x = x0;
double dy = srcHeight / (double) dstHeight;
double y0 = dy / 2.0;
double y = y0;
while (dPtr < dPtrEnd) {
x = x0;
sPtr = srcData + srcWidth * ((int) y);
while (dPtr < dPtrRowEnd) {
*dPtr = sPtr[(int) x];
dPtr++;
x += dx;
}
y += dy;
dPtrRowEnd += dstWidth;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >
int TNearestFInt< TPIXEL, TCHANNEL >::resampleTo_4ch ( TBitmap< TPIXEL, TCHANNEL > &  dst) const
protectedvirtual

Implements app::TFInterpolator< TPIXEL, TCHANNEL >.

Definition at line 18 of file TNearestFInt.cpp.

{
return resampleTo_1ch(dst);
}
template<typename TPIXEL , typename TCHANNEL >
int TFInterpolator< TPIXEL, TCHANNEL >::resampleTo_aliased ( TBitmap< TPIXEL, TCHANNEL > &  dst,
double  force = 1 
) const
virtualinherited

Definition at line 24 of file TFInterpolator.cpp.

{
if (getSrcData() == NULL) {
return 1;
}
TPIXEL * const dstData = dst.getData();
if (dstData == NULL) {
return 2;
}
if (!isInitOk()) {
return 3;
}
unsigned origWidth = getSrcWidth();
unsigned origHeight = getSrcHeight();
unsigned dstWidth = dst.getWidth();
unsigned dstHeight = dst.getHeight();
// Jako sigmu bereme poloměr pixeli, pokud tento po násobení sílou je větší než hraniční, provede se filtrace, ta je ale možná zbytečně agresivní
// a vztah pro určení sigmy je jen od oka... Každopádně filtruje se pro zmenšní o více než 1%, filtrace ale nenaskakuje na nejmenší míře (ta je 0.35, nikoliv 0.505
double xSigma = force * origWidth / (2.0 * dstWidth);
double ySigma = force * origHeight / (2.0 * dstHeight);
xSigma = (xSigma < 0.505) ? 0 : xSigma;
ySigma = (ySigma < 0.505) ? 0 : ySigma;
if (xSigma > 0.35 || ySigma > 0.35) {
TBitmap<TPIXEL, TCHANNEL> * source = new TBitmap<TPIXEL, TCHANNEL>(getSrcData(), getSrcWidth(), getSrcHeight(), dst.getType(), false); // Wrapper
if (source == NULL) {
return 4;
}
if (preBlurred == NULL) {
delete source;
return 5;
}
TGaussianBlur<TPIXEL, TCHANNEL> preBlur(xSigma, ySigma);
preBlur.applyTo(*preBlurred, preBlurred->getRect());
if (i == NULL) {
delete source;
delete preBlurred;
return 6;
}
int retVal = 7;
if (i->isInitOk()) {
retVal = i->resampleTo(dst);
}
delete source;
delete preBlurred;
delete i;
return retVal;
} else {
return resampleTo(dst);
}
}

Member Data Documentation

template<typename TPIXEL, typename TCHANNEL>
const unsigned TNearestFInt< TPIXEL, TCHANNEL >::chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
static

Definition at line 38 of file TNearestFInt.hpp.

template<typename TPIXEL, typename TCHANNEL>
const TCHANNEL TNearestFInt< TPIXEL, TCHANNEL >::maxVal = ~0
static

Definition at line 39 of file TNearestFInt.hpp.

template<typename TPIXEL, typename TCHANNEL>
TPIXEL* app::TNearestFInt< TPIXEL, TCHANNEL >::srcData
protected

Definition at line 24 of file TNearestFInt.hpp.

template<typename TPIXEL, typename TCHANNEL>
unsigned app::TNearestFInt< TPIXEL, TCHANNEL >::srcHeight
protected

Definition at line 26 of file TNearestFInt.hpp.

template<typename TPIXEL, typename TCHANNEL>
unsigned app::TNearestFInt< TPIXEL, TCHANNEL >::srcWidth
protected

Definition at line 25 of file TNearestFInt.hpp.


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