Image Data Structure#

struct ImageData : public FileSection#

This section is for interoperability with different software such as lightroom and holds a composite of all the layers.

When writing out data we fill it with empty pixels using Rle compression, this is due to Photoshop unfortunately requiring it to be present. Due to this compression step we can usually save lots of data over what Photoshop writes out

Public Functions

inline virtual uint64_t calculateSize(std::shared_ptr<FileHeader> header) const override#

Each FileSection must implement a way to calculate its own section size in bytes based on the data it holds. This is important for writing to disk as we sometimes hold a section size marker. The size must include this marker (if applicable) and when writing the marker we subtract the size of it.

Note

Any sections that include image data (LayerAndMaskInformation and ImageData) will not be able to calculate the section size due to offloading the compression to the write step. For these sections the size calculation gets done on write.

Parameters:

header – An optional ptr to the document FileHeader, only some functions require this to be present

inline void write(File &document, const FileHeader &header)#

Write out an empty image data section from the number of channels. This section is unfortunately required.

ImageData() = default#
inline ImageData(uint16_t numChannels)#

Initialize the ImageData with a given number of channels to write out. We do this rather than deducting from the header as the header counts alpha channels while this does not!