Debian Codegraph @

cvd/internal/io/bmp.h

raw symbols SCIP
1 #ifndef BMP_H
2 #define BMP_H
3
4 #include <iostream>
5 #include <memory>
6 #include <string>
7 #include <vector>
8
9 #include <cvd/byte.h>
10 #include <cvd/image.h>
11 #include <cvd/internal/convert_pixel_types.h>
12 #include <cvd/internal/load_and_save.h>
13
14 namespace CVD
15 {
16 namespace BMP
17 {
18 using Internal::Head;
19 using Internal::TypeList;
20
21 class ReadPimpl;
22 class Reader
23 {
24 public:
25 Reader(std::istream& i);
26 ~Reader();
27
28 ImageRef size();
29 bool top_row_first();
30
31 void get_raw_pixel_line(unsigned char*);
32 void get_raw_pixel_line(Rgb<unsigned char>*);
33
34 std::string datatype();
35 std::string name();
36
37 typedef TypeList<byte,
38 TypeList<Rgb<byte>,
39 Head>>
40 Types;
41
42 static bool first_byte_matches(const int b)
43 {
44 return b == 'B';
45 }
46
47 private:
48 std::unique_ptr<ReadPimpl> t;
49 };
50
51 class WritePimpl;
52 class Writer
53 {
54 public:
55 Writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<>>& p);
56 ~Writer();
57
58 void write_raw_pixel_line(const byte*);
59 void write_raw_pixel_line(const Rgb<byte>*);
60
61 template <class Incoming>
62 struct Outgoing
63 {
64 typedef byte type;
65 };
66
67 static const int top_row_first = 0;
68
69 protected:
70 std::unique_ptr<WritePimpl> t;
71 };
72
73 template <class C>
74 struct Writer::Outgoing<Rgb<C>>
75 {
76 typedef Rgb<byte> type;
77 };
78
79 template <class C>
80 struct Writer::Outgoing<Rgba<C>>
81 {
82 typedef Rgb<byte> type;
83 };
84
85 template <>
86 struct Writer::Outgoing<Rgb8>
87 {
88 typedef Rgb<byte> type;
89 };
90
91 }
92 }
93
94 #endif