libfacade 1.1
A library for manipulating PNG images with payloads.
|
The chunk class responsible for parsing the raw data of a PNG file. More...
#include <png.hpp>
Public Member Functions | |
ChunkPtr () | |
ChunkPtr (const ChunkPtr &other) | |
std::size_t | length () const |
Return the length of this parsed chunk data. | |
ChunkTag | tag () const |
Return the chunk tag of this parsed data. | |
std::vector< std::uint8_t > | data () const |
Return a copy of the data in this chunk. | |
std::uint32_t | crc () const |
Return the CRC value of this chunk. | |
bool | validate () const |
Calculate the CRC value of this chunk and validate it against the stored CRC value. | |
std::size_t | chunk_size () const |
Return the size, in bytes, of the full chunk. | |
std::vector< std::uint8_t > | chunk_data () const |
Return all data representing this chunk. | |
ChunkVec | to_chunk_vec () const |
Convert this ChunkPtr into a ChunkVec object. | |
Static Public Member Functions | |
static ChunkPtr | parse (const void *ptr, std::size_t size, std::size_t offset) |
Parse the given buffer for chunk data. | |
static ChunkPtr | parse (const std::vector< std::uint8_t > &vec, std::size_t offset) |
Parse the given vector for chunk data. | |
The chunk class responsible for parsing the raw data of a PNG file.
This should only be used when either parsing chunk data directly from the PNG file or writing said data back into the PNG file. It relies on data outside of itself to function, and it is therefore possible to crash your program if you're not careful with it.
|
inline |
|
inline |
std::vector< std::uint8_t > ChunkPtr::chunk_data | ( | ) | const |
Return all data representing this chunk.
This differs from facade::png::ChunkPtr::data by returning all data, including the length, the tag and the CRC.
std::size_t ChunkPtr::chunk_size | ( | ) | const |
Return the size, in bytes, of the full chunk.
This differs from facade::png::ChunkPtr::length by calculating the length of the full chunk (i.e., includes the length and the CRC), rather than just the chunk's data length.
std::uint32_t ChunkPtr::crc | ( | ) | const |
Return the CRC value of this chunk.
Note that this does not calculate the CRC value– it merely returns the CRC value within the chunk.
std::vector< std::uint8_t > ChunkPtr::data | ( | ) | const |
Return a copy of the data in this chunk.
std::size_t ChunkPtr::length | ( | ) | const |
Return the length of this parsed chunk data.
|
static |
Parse the given vector for chunk data.
vec | The vector to check for chunk data. |
offset | The offset to begin parsing. |
|
static |
Parse the given buffer for chunk data.
ptr | The pointer to the raw PNG chunk data. |
size | The size of the buffer to look at. |
offset | The offset in the buffer to begin looking for a chunk. |
ChunkTag ChunkPtr::tag | ( | ) | const |
Return the chunk tag of this parsed data.
bool ChunkPtr::validate | ( | ) | const |
Calculate the CRC value of this chunk and validate it against the stored CRC value.