PhoenixPNG  0.1.0
Set of tools to ease use of png file
Loading...
Searching...
No Matches
PImagePng.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_H__
8#define __PIMAGEPNG_H__
9
10#include <iostream>
11#include "check_png.h"
12
13#include "PColorMap.h"
14
16typedef unsigned int NbColorByte;
17
20 public:
22 RGB = PNG_COLOR_TYPE_RGB,
23 RGBA = PNG_COLOR_TYPE_RGB_ALPHA
24 };
25
26 PImagePng();
27 PImagePng(const PImagePng & other);
28 virtual ~PImagePng();
29 PImagePng & operator = (const PImagePng & other);
30
31 bool createImage(size_t width, size_t height, PImagePng::ColorType colorType = PImagePng::RGB);
32
33 bool read(const PPath & fileName);
34 bool write(const PPath & fileName);
35
36 void clear();
37
38 void fill(color_t red, color_t green, color_t blue, color_t alpha = 255);
39
40 void setColor(size_t idxWidth, size_t idxHeight, color_t red, color_t green, color_t blue);
41 void setColor(size_t idxWidth, size_t idxHeight, color_t red, color_t green, color_t blue, color_t alpha);
42
43 template<typename T>
44 void setColor(const T * matValue, size_t nbRow, size_t nbCol, const PColorMap & colorMap);
45
46 void getColor(size_t idxWidth, size_t idxHeight, color_t & red, color_t & green, color_t & blue) const;
47 void getColor(size_t idxWidth, size_t idxHeight, color_t & red, color_t & green, color_t & blue, color_t & alpha) const;
48
49 unsigned int getWidth() const;
50 unsigned int getHeight() const;
52
53 const png_byte* getData() const;
54 png_byte* getData();
55
56 protected:
57 void copyPImagePng(const PImagePng & other);
58
59 private:
61
63 png_image p_image;
65 png_byte* p_buffer;
70};
71
72#include "PImagePng_impl.h"
73
74#endif
75
unsigned char color_t
Type des of a color.
Definition PColorMap.h:14
unsigned int NbColorByte
Number of bytes use in the image color (3 for RGB, 4 for RGBA)
Definition PImagePng.h:16
Describe a color map to adapt color with input value.
Definition PColorMap.h:38
Class which manipulate png image.
Definition PImagePng.h:19
void initialisationPImagePng()
Initialisation function of the class PImagePng.
bool createImage(size_t width, size_t height, PImagePng::ColorType colorType=PImagePng::RGB)
Create an image.
Definition PImagePng.cpp:44
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)
void fill(color_t red, color_t green, color_t blue, color_t alpha=255)
Fill the image with the given color.
bool read(const PPath &fileName)
Read the given png image.
Definition PImagePng.cpp:74
NbColorByte getNbBytePerPixel() const
Get the number of bytes per pixel.
png_image p_image
Png image.
Definition PImagePng.h:63
void clear()
Clear the image and buffer.
PImagePng()
Default constructor of PImagePng.
Definition PImagePng.cpp:12
void copyPImagePng(const PImagePng &other)
Copy function of PImagePng.
png_byte * p_buffer
Buffer use to store the image data.
Definition PImagePng.h:65
PImagePng & operator=(const PImagePng &other)
Definition of equal operator of PImagePng.
Definition PImagePng.cpp:33
const png_byte * getData() const
Get the buffer data of the current PImagePng.
PImagePng::ColorType p_colorType
Type of the color of the current image.
Definition PImagePng.h:69
NbColorByte p_nbBytePerPixel
Number of bytes per pixel (3 for RGB, 4 for RGBA)
Definition PImagePng.h:67
virtual ~PImagePng()
Destructor of PImagePng.
Definition PImagePng.cpp:25
unsigned int getHeight() const
Get the height of the image.
void getColor(size_t idxWidth, size_t idxHeight, color_t &red, color_t &green, color_t &blue) const
Get the color of the pixel at (idxWidth, idxHeight)
bool write(const PPath &fileName)
Write a png file.
unsigned int getWidth() const
Get the width of the image.