Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #ifndef __PIMAGEPNG_IMPL_H__ | ||
8 | #define __PIMAGEPNG_IMPL_H__ | ||
9 | |||
10 | #include <algorithm> | ||
11 | #include "PImagePng.h" | ||
12 | |||
13 | ///Set the color of the image by respect to a given matrix of values and the colorMap | ||
14 | /** @param matValue : matrix of value to be used to colorize the PImagePng | ||
15 | * @param nbRow : number of rows of the matrix | ||
16 | * @param nbCol : number of columns of the matrix | ||
17 | * @param colorMap : PColorMap to be used to convert values in color | ||
18 | */ | ||
19 | template<typename T> | ||
20 | 1 | void PImagePng::setColor(const T * matValue, size_t nbRow, size_t nbCol, const PColorMap & colorMap){ | |
21 | 1 | size_t nbValueRow(std::min(nbRow, (size_t)p_image.height)); | |
22 | 1 | size_t nbValueCol(std::min(nbCol, (size_t)p_image.width)); | |
23 | |||
24 |
2/2✓ Branch 0 (11→5) taken 480 times.
✓ Branch 1 (11→12) taken 1 times.
|
481 | for(size_t i(0lu); i < nbValueRow; ++i){ |
25 |
2/2✓ Branch 0 (9→6) taken 307200 times.
✓ Branch 1 (9→10) taken 480 times.
|
307680 | for(size_t j(0lu); j < nbValueCol; ++j){ |
26 | 307200 | float value(matValue[i*nbCol + j]); | |
27 | 307200 | color_t red(0), green(0), blue(0), alpha(0); | |
28 |
1/1✓ Branch 0 (6→7) taken 307200 times.
|
307200 | colorMap.interpolate(red, green, blue, alpha, value); |
29 |
1/1✓ Branch 0 (7→8) taken 307200 times.
|
307200 | setColor(j, i, red, green, blue, alpha); |
30 | } | ||
31 | } | ||
32 | |||
33 | 1 | } | |
34 | |||
35 | #endif | ||
36 | |||
37 |