Debian Codegraph @

cvd/internal/io/cvdimage.h

raw symbols SCIP
1 #ifndef PNM_CVDIMAGE_H
2 #define PNM_CVDIMAGE_H
3
4 #include <iostream>
5 #include <memory>
6 #include <string>
7 #include <vector>
8
9 #include <cvd/byte.h>
10 #include <cvd/colourspaces.h>
11 #include <cvd/image.h>
12 #include <cvd/internal/convert_pixel_types.h>
13 #include <cvd/internal/load_and_save.h>
14
15 namespace CVD
16 {
17 namespace CVDimage
18 {
19
20 using CVD::Internal::Head;
21 using CVD::Internal::TypeList;
22
23 class ReadPimpl;
24 class Reader
25 {
26 public:
27 Reader(std::istream&);
28 ~Reader();
29
30 ImageRef size();
31 bool top_row_first();
32
33 void get_raw_pixel_line(unsigned char*);
34 void get_raw_pixel_line(bayer_bggr*);
35 void get_raw_pixel_line(bayer_rggb*);
36 void get_raw_pixel_line(bayer_grbg*);
37 void get_raw_pixel_line(bayer_gbrg*);
38 void get_raw_pixel_line(Rgb<unsigned char>*);
39 void get_raw_pixel_line(Rgba<unsigned char>*);
40
41 std::string datatype();
42 std::string name();
43
44 typedef TypeList<byte,
45 TypeList<bayer_bggr,
46 TypeList<bayer_rggb,
47 TypeList<bayer_grbg,
48 TypeList<bayer_gbrg,
49 TypeList<Rgb<byte>,
50 TypeList<Rgba<byte>,
51 Head>>>>>>>
52 Types;
53
54 static bool first_byte_matches(const int b)
55 {
56 return b == 'C';
57 }
58
59 private:
60 std::unique_ptr<ReadPimpl> t;
61 };
62
63 class WritePimpl;
64
65 class writer
66 {
67 public:
68 writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<>>& p);
69 ~writer();
70
71 void write_raw_pixel_line(const byte*);
72 void write_raw_pixel_line(const bayer_bggr*);
73 void write_raw_pixel_line(const bayer_rggb*);
74 void write_raw_pixel_line(const bayer_grbg*);
75 void write_raw_pixel_line(const bayer_gbrg*);
76 void write_raw_pixel_line(const Rgb<byte>*);
77 void write_raw_pixel_line(const Rgba<byte>*);
78
79 template <class Incoming>
80 struct Outgoing
81 {
82 typedef byte type;
83 };
84
85 static const int top_row_first = 1;
86
87 protected:
88 std::unique_ptr<WritePimpl> t;
89 };
90
91 template <>
92 struct writer::Outgoing<bayer_bggr>
93 {
94 typedef bayer_bggr type;
95 };
96
97 template <>
98 struct writer::Outgoing<bayer_rggb>
99 {
100 typedef bayer_rggb type;
101 };
102
103 template <>
104 struct writer::Outgoing<bayer_grbg>
105 {
106 typedef bayer_grbg type;
107 };
108
109 template <>
110 struct writer::Outgoing<bayer_gbrg>
111 {
112 typedef bayer_gbrg type;
113 };
114
115 template <class C>
116 struct writer::Outgoing<Rgb<C>>
117 {
118 typedef Rgb<byte> type;
119 };
120
121 template <class C>
122 struct writer::Outgoing<Rgba<C>>
123 {
124 typedef Rgba<byte> type;
125 };
126
127 template <>
128 struct writer::Outgoing<Rgb8>
129 {
130 typedef Rgb<byte> type;
131 };
132
133 }
134 }
135
136 #endif