PhoenixPNG  0.1.0
Set of tools to ease use of png file
Loading...
Searching...
No Matches
PImagePng_impl.h
Go to the documentation of this file.
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
14
19template<typename T>
20void PImagePng::setColor(const T * matValue, size_t nbRow, size_t nbCol, const PColorMap & colorMap){
21 size_t nbValueRow(std::min(nbRow, (size_t)p_image.height));
22 size_t nbValueCol(std::min(nbCol, (size_t)p_image.width));
23
24 for(size_t i(0lu); i < nbValueRow; ++i){
25 for(size_t j(0lu); j < nbValueCol; ++j){
26 float value(matValue[i*nbCol + j]);
27 color_t red(0), green(0), blue(0), alpha(0);
28 colorMap.interpolate(red, green, blue, alpha, value);
29 setColor(j, i, red, green, blue, alpha);
30 }
31 }
32
33}
34
35#endif
36
unsigned char color_t
Type des of a color.
Definition PColorMap.h:14
Describe a color map to adapt color with input value.
Definition PColorMap.h:38
void interpolate(color_t &red, color_t &green, color_t &blue, float value) const
Interpolate color by respect to the given value.
void setColor(size_t idxWidth, size_t idxHeight, color_t red, color_t green, color_t blue)
Set the color of the pixel at (idxWidth, idxHeight)
png_image p_image
Png image.
Definition PImagePng.h:63