File Header Structure#

struct FileHeader : public FileSection#

Public Functions

FileHeader() = default#
inline FileHeader(Enum::Version version, uint16_t numChannels, uint32_t width, uint32_t height, Enum::BitDepth depth, Enum::ColorMode colorMode)#
void read(File &document)#

Read and Initialize the FileHeader from disk.

void write(File &document)#

Write out the data held by the struct in a Photoshop compliant way.

inline void initialize(size_t offset, size_t size) noexcept#

Initialize the file section with a size and offset. If re-initialization is needed this function may be called again

template<typename T = size_t>
inline T size() const#

Get the size of the FileSection as the given integral type checking internally if this access would overflow the template argument T. This function is primarily intended for structures such as a PascalString which may only be a max of uint8_t in size.

inline void size(size_t size) noexcept#

Set the size of the file section.

inline void addSize(size_t increment)#

Add to the size of the FileSection.

inline size_t offset() const noexcept#

Public Members

Signature m_Signature = {}#

Has to be ‘8BPS’.

Enum::Version m_Version = {}#

The type of file we are dealing with.

uint16_t m_NumChannels = {}#

Supported range by Photoshop is 1-56. This does not account for mask channels.

uint32_t m_Height = {}#

1 - 30,000 for PSD and 1 - 300,000 for PSB

uint32_t m_Width = {}#

1 - 30,000 for PSD and 1 - 300,000 for PSB

Enum::BitDepth m_Depth = {}#

Depth of the Document.

Enum::ColorMode m_ColorMode = {}#

Color Mode of the file.

Public Static Functions

static FileHeader from_bytes(const std::vector<uint8_t> &file_data)#

Initialize a file header from bytes.

Parameters:

file_data – The full file data.

Returns:

The deserialized FileHeader

static inline constexpr size_t get_size()#

Return the section size without parsing the whole struct.