libfacade 1.1
A library for manipulating PNG images with payloads.
Loading...
Searching...
No Matches
payload.hpp
Go to the documentation of this file.
1#ifndef __FACADE_PAYLOAD_HPP
2#define __FACADE_PAYLOAD_HPP
3
8
9#include <facade/png.hpp>
10#include <facade/ico.hpp>
11
12namespace facade
13{
29 class
30 EXPORT
31 PNGPayload : public png::Image
32 {
33 public:
34 PNGPayload() : png::Image() {}
35 PNGPayload(const void *ptr, std::size_t size) : png::Image(ptr, size) {}
36 PNGPayload(const std::vector<std::uint8_t> &vec) : png::Image(vec) {}
37 PNGPayload(const std::string &filename) : png::Image(filename) {}
38 PNGPayload(const PNGPayload &other) : png::Image(other) {}
39
50 png::Text &add_text_payload(const std::string &keyword, const void *ptr, std::size_t size);
51
61 png::Text &add_text_payload(const std::string &keyword, const std::vector<std::uint8_t> &data);
62
67 void remove_text_payload(const png::Text &payload);
68
74 std::vector<png::Text> get_text_payloads(const std::string &keyword) const;
75
82 std::vector<std::vector<std::uint8_t>> extract_text_payloads(const std::string &keyword) const;
83
94 png::ZText &add_ztext_payload(const std::string &keyword, const void *ptr, std::size_t size);
95
105 png::ZText &add_ztext_payload(const std::string &keyword, const std::vector<std::uint8_t> &data);
106
111 void remove_ztext_payload(const png::ZText &payload);
112
119 std::vector<png::ZText> get_ztext_payloads(const std::string &keyword) const;
120
128 std::vector<std::vector<std::uint8_t>> extract_ztext_payloads(const std::string &keyword) const;
129
142 std::vector<std::uint8_t> read_stego_data(std::size_t bit_offset, std::size_t size) const;
155 void write_stego_data(const void *ptr, std::size_t size, std::size_t bit_offset);
167 void write_stego_data(const std::vector<std::uint8_t> &data, std::size_t bit_offset);
168
173 bool has_stego_payload() const;
181 PNGPayload create_stego_payload(const void *ptr, std::size_t size) const;
188 PNGPayload create_stego_payload(const std::vector<std::uint8_t> &data) const;
194 std::vector<std::uint8_t> extract_stego_payload() const;
195 };
196
204 class
205 EXPORT
206 ICOPayload : public ico::Icon
207 {
208 std::optional<std::size_t> _index;
209 std::optional<PNGPayload> _payload;
210
211 public:
212 ICOPayload() : ico::Icon() {}
213 ICOPayload(const void *ptr, std::size_t size) : ico::Icon(ptr, size) { this->find_png(); }
214 ICOPayload(const std::vector<std::uint8_t> &vec) : ico::Icon(vec) { this->find_png(); }
215 ICOPayload(const std::string &filename) : ico::Icon(filename) { this->find_png(); }
216 ICOPayload(const ICOPayload &other) : _index(other._index), _payload(other._payload), ico::Icon(other) {}
217
218 ICOPayload &operator=(const ICOPayload &other);
220 PNGPayload *operator->(void);
222 PNGPayload &operator*(void);
223
227 PNGPayload &png_payload(void);
231 const PNGPayload &png_payload(void) const;
232
236 void find_png(void);
238 void reset_png(void);
242 void set_png(void);
243 };
244}
245
246#endif
An icon file containing a payload.
Definition: payload.hpp:207
ICOPayload()
Definition: payload.hpp:212
ICOPayload(const ICOPayload &other)
Definition: payload.hpp:216
ICOPayload(const std::vector< std::uint8_t > &vec)
Definition: payload.hpp:214
ICOPayload(const void *ptr, std::size_t size)
Definition: payload.hpp:213
ICOPayload(const std::string &filename)
Definition: payload.hpp:215
A PNG-based payload helper class.
Definition: payload.hpp:32
PNGPayload(const std::string &filename)
Definition: payload.hpp:37
PNGPayload(const void *ptr, std::size_t size)
Definition: payload.hpp:35
PNGPayload()
Definition: payload.hpp:34
PNGPayload(const PNGPayload &other)
Definition: payload.hpp:38
PNGPayload(const std::vector< std::uint8_t > &vec)
Definition: payload.hpp:36
A Windows icon file.
Definition: ico.hpp:55
A class for loading and manipulating PNG images.
Definition: png.hpp:1305
A tEXt chunk object.
Definition: png.hpp:906
A compressed text chunk.
Definition: png.hpp:958
Code functionality for handling Windows icon files.
Definition: exception.hpp:14
#define EXPORT
Definition: platform.hpp:46
Code functionality for dealing with PNG images.