View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

netpbmimage.h
Go to the documentation of this file.
1#ifndef VISTLE_PPMIMAGE_H
2#define VISTLE_PPMIMAGE_H
3
4#include "export.h"
5
6#include <string>
7#include <cstdio>
8#include <vector>
9#include <limits>
10#include <ostream>
11
12namespace vistle {
13
15public:
16 enum Format {
17 PBM, // bitmap: black&white
18 Bitmap = PBM,
19 PGM, // gray scale
20 Graymap = PGM,
21 PPM, // rgb color
22 Color = PPM,
23 };
24 NetpbmImage(const std::string &name);
25 NetpbmImage(const std::string &name, unsigned width, unsigned height, Format = PPM, unsigned highest = 0);
26 virtual ~NetpbmImage();
27 bool close();
28
29 Format format() const;
30 unsigned width() const;
31 unsigned height() const;
32
33 unsigned min() const;
34 unsigned max() const;
35
36 bool complete() const;
37
38 bool append(float r, float g, float b);
39 bool append(float gray);
40
41 const float *gray() const;
42 const unsigned char *rgb() const;
43
44protected:
45 size_t m_numwritten = 0;
46 unsigned m_width = 0, m_height = 0;
47 unsigned m_highest = 255;
48 Format m_format = PPM;
49 FILE *m_fp = nullptr;
50 unsigned m_min = std::numeric_limits<unsigned>::max(), m_max = 0;
51
52 std::vector<float> m_gray;
53 std::vector<unsigned char> m_rgba;
54
55 void increaseRange(unsigned value);
56};
57
58V_UTILEXPORT std::ostream &operator<<(std::ostream &s, const NetpbmImage &img);
59
60} // namespace vistle
61#endif
Definition: netpbmimage.h:14
Format
Definition: netpbmimage.h:16
@ PBM
Definition: netpbmimage.h:17
@ PGM
Definition: netpbmimage.h:19
@ PPM
Definition: netpbmimage.h:21
std::vector< float > m_gray
Definition: netpbmimage.h:52
std::vector< unsigned char > m_rgba
Definition: netpbmimage.h:53
static T min(T a, T b)
Definition: messages.cpp:28
Definition: allobjects.cpp:30
std::ostream & operator<<(std::ostream &out, const Meta &meta)
Definition: objectmeta.cpp:45
#define V_UTILEXPORT
Definition: export.h:19