Commit 9aa17d71 authored by Laurent Claustre's avatar Laurent Claustre
Browse files

pixmaptools : move code to satisfy new compiler

parent 026d353a
......@@ -294,29 +294,7 @@ void LUT::Palette::_calcPalette(unsigned int palette[],int fmin, int fmax,
*pal = *(_dataPalette + int(A * theLutConfiguration.log(j) + B));
}
// LUT TEMPLATE
/** @brief transform <b>data</b> to an image using the palette give in args
*
* autoscale data on min/max
* @param data the data source array
* @param anImagePt a data dest array it size must be >= sizeof(int) * nb pixel
* @param column the number of column of the source data
* @param row the number of row of the source data
* @param aPalette the palette colormap used to transform source data to an image
* @param aMeth the mapping methode
* @param dataMin return the min data value
* @param dataMax return the max data value
*/
template<class IN> __attribute__ ((used)) void LUT::map_on_min_max_val(const IN *data,unsigned int *anImagePt,int column,int row,Palette &aPalette,
mapping_meth aMeth,
IN &dataMin,IN &dataMax)
{
if(aMeth != LOG)
_find_min_max(data,column * row,dataMin,dataMax);
else
_find_minpos_max(data,column * row,dataMin,dataMax);
map(data,anImagePt,column,row,aPalette,aMeth,dataMin,dataMax);
}
/** @brief calculate the average and the standard deviation
*/
template<class IN,class MIN_MAX_TYPE>
......@@ -377,6 +355,31 @@ template<class IN> static __attribute__ ((used)) void _find_minpos_max(const IN
else if(*aData > 0. && (*aData < dataMin || dataMin == 0)) dataMin = *aData;
}
}
// LUT TEMPLATE
/** @brief transform <b>data</b> to an image using the palette give in args
*
* autoscale data on min/max
* @param data the data source array
* @param anImagePt a data dest array it size must be >= sizeof(int) * nb pixel
* @param column the number of column of the source data
* @param row the number of row of the source data
* @param aPalette the palette colormap used to transform source data to an image
* @param aMeth the mapping methode
* @param dataMin return the min data value
* @param dataMax return the max data value
*/
template<class IN> __attribute__ ((used)) void LUT::map_on_min_max_val(const IN *data,unsigned int *anImagePt,int column,int row,Palette &aPalette,
mapping_meth aMeth,
IN &dataMin,IN &dataMax)
{
if(aMeth != LOG)
_find_min_max(data,column * row,dataMin,dataMax);
else
_find_minpos_max(data,column * row,dataMin,dataMax);
map(data,anImagePt,column,row,aPalette,aMeth,dataMin,dataMax);
}
template<class IN> __attribute__ ((used)) void LUT::map(const IN *data,unsigned int *anImagePt,int column,int line,Palette &aPalette,
LUT::mapping_meth aMeth,
IN dataMin,IN dataMax)
......@@ -401,64 +404,6 @@ template<class IN> __attribute__ ((used)) void LUT::map(const IN *data,unsigned
_data_map(data,anImagePt,column,line,aMeth,aUsePalette,dataMin,dataMax);
}
template<class IN> static __attribute__ ((used)) void _data_map(const IN *data,unsigned int *anImagePt,int column,int line,
LUT::mapping_meth aMeth,unsigned int *aPalette,
IN dataMin,IN dataMax) throw()
{
static const int mapmin = 0;
static const int mapmax = 0xffff;
double A, B;
double lmin,lmax;
IN shift = 0;
if ((dataMax-dataMin) != 0)
{
if (aMeth == LUT::LINEAR)
{
lmin = double(dataMin);
lmax = double(dataMax);
}
else if(aMeth == LUT::SHIFT_LOG)
{
if(dataMin <= 0)
{
shift = -dataMin;
if(shift < 1e-6) shift += IN(1);
dataMax += shift;
dataMin += shift;
}
lmin = log10(dataMin);
lmax = log10(dataMax);
}
else
{
if(dataMin == 0)
dataMin = IN(1);
else if(dataMin <= 0)
dataMin = IN(1e-6);
lmin = log10(dataMin);
lmax = log10(dataMax);
}
A = (mapmax - mapmin) / (lmax - lmin);
B = mapmin - ((mapmax - mapmin) * lmin) / (lmax-lmin);
}
else
{
A = 1.0;
B = 0.0;
}
if(aMeth == LUT::LINEAR)
_linear_data_map(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax);
else
{
if(shift < 1e-6)
_log_data_map(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax);
else
_log_data_map_shift(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax,shift);
}
}
// LINEAR MAPPING FCT
......@@ -552,6 +497,8 @@ template<> void _linear_data_map(unsigned char const *data,unsigned int *anImage
*anImagePt = *palette;
}
}
template<class IN> static __attribute__ ((used)) void _log_data_map(const IN *data,unsigned int *anImagePt,int column,int line,
unsigned int *aPalette,double A,double B,
IN dataMin,IN dataMax) throw()
......@@ -591,6 +538,65 @@ template<class IN> static __attribute__ ((used)) void _log_data_map_shift(const
}
}
template<class IN> static __attribute__ ((used)) void _data_map(const IN *data,unsigned int *anImagePt,int column,int line,
LUT::mapping_meth aMeth,unsigned int *aPalette,
IN dataMin,IN dataMax) throw()
{
static const int mapmin = 0;
static const int mapmax = 0xffff;
double A, B;
double lmin,lmax;
IN shift = 0;
if ((dataMax-dataMin) != 0)
{
if (aMeth == LUT::LINEAR)
{
lmin = double(dataMin);
lmax = double(dataMax);
}
else if(aMeth == LUT::SHIFT_LOG)
{
if(dataMin <= 0)
{
shift = -dataMin;
if(shift < 1e-6) shift += IN(1);
dataMax += shift;
dataMin += shift;
}
lmin = log10(dataMin);
lmax = log10(dataMax);
}
else
{
if(dataMin == 0)
dataMin = IN(1);
else if(dataMin <= 0)
dataMin = IN(1e-6);
lmin = log10(dataMin);
lmax = log10(dataMax);
}
A = (mapmax - mapmin) / (lmax - lmin);
B = mapmin - ((mapmax - mapmin) * lmin) / (lmax-lmin);
}
else
{
A = 1.0;
B = 0.0;
}
if(aMeth == LUT::LINEAR)
_linear_data_map(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax);
else
{
if(shift < 1e-6)
_log_data_map(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax);
else
_log_data_map_shift(data,anImagePt,column,line,aPalette,A,B,dataMin,dataMax,shift);
}
}
static __attribute__ ((used)) void init_template()
{
#define INIT_MAP(TYPE) \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment