App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <TLUT.hpp>`

## Public Member Functions
| TLUT (int init=0)
virtual | ~TLUT ()
TCHANNEL ** | getValues ()
int | isInitOk ()
int | applyTo (TBitmap< TPIXEL, TCHANNEL > &dst, Rect dstRect)
int | applyTo (TBitmap< TPIXEL, TCHANNEL > &dst, Rect dstRect, double alpha)
int | applyTo (TBitmap< TPIXEL, TCHANNEL > &dst, const TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig)
int | applyTo (TBitmap< TPIXEL, TCHANNEL > &dst, const TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig, double alpha)

## Static Public Attributes
static const unsigned | chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
static const TCHANNEL | maxVal = ~0
static const unsigned | numVals = maxVal + 1

## Protected Member Functions
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &dst, Rect dstRect)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &dst, Rect dstRect, double alpha)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &dst, const TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig)
virtual int | applyTo_4ch (TBitmap< TPIXEL, TCHANNEL > &dst, const TBitmap< TCHANNEL, TCHANNEL > &msk, Rect mskRect, Point mskOrig, double alpha)

## Protected Attributes
TCHANNEL * | values [4]
int | initOk

## Detailed Description

### template<typename TPIXEL, typename TCHANNEL>
class app::TLUT< TPIXEL, TCHANNEL >

Definition at line 18 of file TLUT.hpp.

## Constructor & Destructor Documentation

template<typename TPIXEL, typename TCHANNEL>

app::TLUT< TPIXEL, TCHANNEL >::TLUT | ( | int | init = `0` | ) |
| inline

Definition at line 35 of file TLUT.hpp.

{
int dim = (chCount <= 4) ? chCount : 4;
int i = 0;
initOk = 1;
while (i < dim) {
values[i] = (TCHANNEL *) malloc((unsigned long int) (numVals * sizeof(TCHANNEL))); // ANDROID_SPECIFIC přetypování v malloc
if (values[i] == NULL) {
initOk = 0;
}
if (init) {
if (i == 0) {
TCHANNEL * ptr = values[i];
TCHANNEL * ptrEnd = ptr + numVals;
TCHANNEL j = 0;
while (ptr < ptrEnd) {
*ptr = j++;
ptr++;
}
} else {
memcpy(values[i], values[0], (numVals) * sizeof(TCHANNEL));
}
}
i++;
}
if (initOk) {
while (i < 4) {
values[i] = NULL;
i++;
}
} else {
for (int i = 0; i < 4; i++) {
if (values[i] != NULL) {
free(values[i]);
values[i] = NULL;
}
}
}
}
template<typename TPIXEL , typename TCHANNEL >

TLUT< TPIXEL, TCHANNEL >::~TLUT | ( |  | ) |
| virtual

Definition at line 219 of file TLUT.cpp.

{
for (int i = 0; i < 4; i++) {
if (values[i] != NULL) {
free(values[i]);
values[i] = NULL;
}
}
}

## Member Function Documentation

template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | Rect | dstRect
| ) |  |
| inline

Definition at line 83 of file TLUT.hpp.

{
switch (chCount) {
case 4:
return applyTo_4ch(dst, dstRect);
break;
default:
return 1000;
break;
}
}
template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | Rect | dstRect,
|  | double | alpha
| ) |  |
| inline

Definition at line 93 of file TLUT.hpp.

{
switch (chCount) {
case 4:
return applyTo_4ch(dst, dstRect, alpha);
break;
default:
return 1000;
break;
}
}
template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | const TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig
| ) |  |
| inline

Definition at line 103 of file TLUT.hpp.

{
switch (chCount) {
case 4:
return applyTo_4ch(dst, msk, mskRect, mskOrig);
break;
default:
return 1000;
break;
}
}
template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::applyTo | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | const TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig,
|  | double | alpha
| ) |  |
| inline

Definition at line 113 of file TLUT.hpp.

{
switch (chCount) {
case 4:
return applyTo_4ch(dst, msk, mskRect, mskOrig, alpha);
break;
default:
return 1000;
break;
}
}
template<typename TPIXEL , typename TCHANNEL >

int TLUT< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | Rect | dstRect
| ) |  |
| protectedvirtual

Definition at line 15 of file TLUT.cpp.

{
if (dst.getData() == NULL) {
return 1;
}
if (!initOk) {
return 2;
}
PointerArea dstArea = PointerArea(dst.getData(), dst.getRect(), dstRect, dst.getBpp());
TCHANNEL * rLut = values[0];
TCHANNEL * gLut = values[1];
TCHANNEL * bLut = values[2];
TCHANNEL * aLut = values[3];
TCHANNEL * d = (TCHANNEL *) dstArea.getAreaBgn();
TCHANNEL * dstAreaEnd = (TCHANNEL *) dstArea.getAreaEnd();
TCHANNEL * dstAreaRowEnd = (TCHANNEL *) dstArea.getAreaRowEnd();
unsigned dstWidth = dstArea.getOrigWidth() * 4;
unsigned dstOffset = (dstArea.getOrigWidth() - dstArea.getAreaWidth()) * 4;
while (d < dstAreaEnd) {
while (d < dstAreaRowEnd) {
*d = rLut[*d];
d++;
*d = gLut[*d];
d++;
*d = bLut[*d];
d++;
*d = aLut[*d];
d++;
}
d += dstOffset;
dstAreaRowEnd += dstWidth;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUT< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | Rect | dstRect,
|  | double | alpha
| ) |  |
| protectedvirtual

Definition at line 53 of file TLUT.cpp.

{
if (dst.getData() == NULL) {
return 1;
}
if (!initOk) {
return 2;
}
PointerArea dstArea = PointerArea(dst.getData(), dst.getRect(), dstRect, dst.getBpp());
TCHANNEL * rLut = values[0];
TCHANNEL * gLut = values[1];
TCHANNEL * bLut = values[2];
TCHANNEL * aLut = values[3];
TCHANNEL * d = (TCHANNEL *) dstArea.getAreaBgn();
TCHANNEL * dstAreaEnd = (TCHANNEL *) dstArea.getAreaEnd();
TCHANNEL * dstAreaRowEnd = (TCHANNEL *) dstArea.getAreaRowEnd();
unsigned dstWidth = dstArea.getOrigWidth() * 4;
unsigned dstOffset = (dstArea.getOrigWidth() - dstArea.getAreaWidth()) * 4;
while (d < dstAreaEnd) {
while (d < dstAreaRowEnd) {
TCHANNEL doa = *(d + 3);
double da = doa / 255.0;
double sa = aLut[doa] * alpha / 255.0;
double sac = 1 - sa;
double ra = sa + da * sac;
*d = ((rLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((gLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((bLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ra * 255 + 0.5;
d++;
}
d += dstOffset;
dstAreaRowEnd += dstWidth;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUT< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | const TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig
| ) |  |
| protectedvirtual

Definition at line 97 of file TLUT.cpp.

{
if (msk.getType() != MONO || msk.getData() == NULL) {
return 1;
}
if (dst.getType() != RGBA || dst.getData() == NULL) {
return 2;
}
if (!initOk) {
return 2;
}
PointerArea mskArea = PointerArea(msk.getData(), msk.getRect(), mskRect, msk.getBpp());
PointerArea dstArea = dst.getPointerArea();
int err = PointerArea::makeCommon(dstArea, mskArea, mskOrig);
if (err) {
return 100 + err;
}
TCHANNEL * rLut = values[0];
TCHANNEL * gLut = values[1];
TCHANNEL * bLut = values[2];
TCHANNEL * aLut = values[3];
TCHANNEL * d = (TCHANNEL *) dstArea.getAreaBgn();
TCHANNEL * m = (TCHANNEL *) mskArea.getAreaBgn();
TCHANNEL * dstAreaEnd = (TCHANNEL *) dstArea.getAreaEnd();
TCHANNEL * dstAreaRowEnd = (TCHANNEL *) dstArea.getAreaRowEnd();
unsigned dstWidth = dstArea.getOrigWidth() * 4;
unsigned dstOffset = (dstArea.getOrigWidth() - dstArea.getAreaWidth()) * 4;
unsigned mskOffset = mskArea.getOrigWidth() - mskArea.getAreaWidth();
while (d < dstAreaEnd) {
while (d < dstAreaRowEnd) {
TCHANNEL doa = *(d + 3);
double da = doa / 255.0;
double sa = aLut[doa] * *m / 65025.0;
double sac = 1 - sa;
double ra = sa + da * sac;
m++;
*d = ((rLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((gLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((bLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ra * 255 + 0.5;
d++;
}
d += dstOffset;
m += mskOffset;
dstAreaRowEnd += dstWidth;
}
return 0;
}
template<typename TPIXEL , typename TCHANNEL >

int TLUT< TPIXEL, TCHANNEL >::applyTo_4ch | ( | TBitmap< TPIXEL, TCHANNEL > & | dst,
|  | const TBitmap< TCHANNEL, TCHANNEL > & | msk,
|  | Rect | mskRect,
|  | Point | mskOrig,
|  | double | alpha
| ) |  |
| protectedvirtual

Definition at line 159 of file TLUT.cpp.

{
if (msk.getType() != MONO || msk.getData() == NULL) {
return 1;
}
if (dst.getType() != RGBA || dst.getData() == NULL) {
return 2;
}
if (!initOk) {
return 2;
}
PointerArea mskArea = PointerArea(msk.getData(), msk.getRect(), mskRect, msk.getBpp());
PointerArea dstArea = dst.getPointerArea();
int err = PointerArea::makeCommon(dstArea, mskArea, mskOrig);
if (err) {
return 100 + err;
}
TCHANNEL * rLut = values[0];
TCHANNEL * gLut = values[1];
TCHANNEL * bLut = values[2];
TCHANNEL * aLut = values[3];
TCHANNEL * d = (TCHANNEL *) dstArea.getAreaBgn();
// TCHANNEL * m = (TCHANNEL *) msk.getData();
TCHANNEL * m = (TCHANNEL *) mskArea.getAreaBgn();
TCHANNEL * dstAreaEnd = (TCHANNEL *) dstArea.getAreaEnd();
TCHANNEL * dstAreaRowEnd = (TCHANNEL *) dstArea.getAreaRowEnd();
unsigned dstWidth = dstArea.getOrigWidth() * 4;
unsigned dstOffset = (dstArea.getOrigWidth() - dstArea.getAreaWidth()) * 4;
unsigned mskOffset = mskArea.getOrigWidth() - mskArea.getAreaWidth();
while (d < dstAreaEnd) {
while (d < dstAreaRowEnd) {
TCHANNEL doa = *(d + 3);
double da = doa / 255.0;
double sa = aLut[doa] * *m * alpha/ 65025.0;
double sac = 1 - sa;
double ra = sa + da * sac;
m++;
*d = ((rLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((gLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ((bLut[*d] * sa + *d * da * sac) / ra + 0.5);
d++;
*d = ra * 255 + 0.5;
d++;
}
d += dstOffset;
m += mskOffset;
dstAreaRowEnd += dstWidth;
}
return 0;
}
template<typename TPIXEL, typename TCHANNEL>

TCHANNEL** app::TLUT< TPIXEL, TCHANNEL >::getValues | ( |  | ) |
| inline

Definition at line 75 of file TLUT.hpp.

{
return values;
}
template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::isInitOk | ( |  | ) |
| inline

Definition at line 79 of file TLUT.hpp.

{
return initOk;
}

## Member Data Documentation

template<typename TPIXEL, typename TCHANNEL>

const unsigned TLUT< TPIXEL, TCHANNEL >::chCount = sizeof(TPIXEL) / sizeof(TCHANNEL)
| static

Definition at line 31 of file TLUT.hpp.

template<typename TPIXEL, typename TCHANNEL>

int app::TLUT< TPIXEL, TCHANNEL >::initOk
| protected

Definition at line 22 of file TLUT.hpp.

template<typename TPIXEL, typename TCHANNEL>

const TCHANNEL TLUT< TPIXEL, TCHANNEL >::maxVal = ~0
| static

Definition at line 32 of file TLUT.hpp.

template<typename TPIXEL, typename TCHANNEL>

const unsigned TLUT< TPIXEL, TCHANNEL >::numVals = maxVal + 1
| static

Definition at line 33 of file TLUT.hpp.

template<typename TPIXEL, typename TCHANNEL>

TCHANNEL* app::TLUT< TPIXEL, TCHANNEL >::values[4]
| protected

Definition at line 21 of file TLUT.hpp.

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

- /home/xxx/eclipse_workspaces/app/appcore/jni/app/pointops_new/TLUT.hpp
- /home/xxx/eclipse_workspaces/app/appcore/jni/app/pointops_new/TLUT.cpp