Structure Description: ImageChannel#
This is the structure used by the PhotoshopAPI to refer to a single channel. It uses in-memory compression to reduce the memory footprint. For more information on what this is please visit Concept: In Memory Compression
-
struct ImageChannel#
A generic Image Channel that is used by both the PhotoshopFile and LayeredFile, being moved between these two It is entirely valid to have each channel have a different compression method, width and height. We only store the image data in here but do not deal with reading or writing it. Ownership of the image data belongs to this struct and gets freed on destruction or extraction
Public Functions
-
inline int32_t getWidth() const#
Get the width of the uncompressed ImageChannel.
-
inline int32_t getHeight() const#
Get the height of the uncompressed ImageChannel.
-
inline float getCenterX() const#
Get the x-coordinate of the uncompressed ImageChannel.
-
inline float getCenterY() const#
Get the y-coordinate of the uncompressed ImageChannel.
-
inline uint64_t getNumChunks() const#
Get the total number of chunks held in the ImageChannel.
-
template<typename T>
inline std::vector<T> extractData(size_t numThreads = 0)# Extract the data from the image channel and invalidate it (can only be called once). If the image data does not exist yet we simply return an empty vector<T>. If the data was already freed we throw
- Parameters:
numThreads – The number of threads to use for decompression. By default this is 0 which will set it to hardware_concurrency. If you are calling this in a non-threaded environment this is likely the option you should choose
-
template<typename T>
inline void extractData(std::span<T> buffer, size_t numThreads = 0)# Extract the data from the image channel and invalidate it (can only be called once). If the image data does not exist yet we simply return an empty vector<T>. If the data was already freed we throw
- Parameters:
buffer – A preallocated buffer whose size matches that of m_OrigByteSize / sizeof(T). If this is not given we throw an error
numThreads – The number of threads to use for decompression. By default this is 0 which will set it to hardware_concurrency. If you are calling this in a non-threaded environment this is likely the option you should choose
-
template<typename T>
inline void getData(std::span<T> buffer, size_t numThreads = 0)# Copy the image data out of the ImageChannel using a preallocated buffer, does not free the data afterwards. If the data was already freed we throw
- Parameters:
buffer – A preallocated buffer whose size matches that of m_OrigByteSize / sizeof(T). If this is not given we throw an error
numThreads – The number of threads to use for decompression. By default this is 0 which will set it to hardware_concurrency. If you are calling this in a non-threaded environment this is likely the option you should choose
-
template<typename T>
inline std::vector<T> getData(size_t numThreads = 0)# Copy the image data out of the ImageChannel, does not free the data afterwards. Returns an empty vector if the data does not exist yet. If the data was already freed we throw
- Parameters:
numThreads – The number of threads to use for decompression. By default this is 0 which will set it to hardware_concurrency. If you are calling this in a non-threaded environment this is likely the option you should choose
-
template<typename T>
inline std::vector<std::vector<T>> getRandomChunks(const FileHeader header, uint16_t numChunks) const# Extract n amount of randomly selected chunks from the ImageChannel super chunk. This does not invalidate any data and is useful to e.g. compress these chunks using photoshops compression methods to estimate the final size on disk
-
template<typename T>
inline ImageChannel(Enum::Compression compression, const std::vector<T> &imageData, const Enum::ChannelIDInfo channelID, const int32_t width, const int32_t height, const float xcoord, const float ycoord)# Take a reference to a decompressed image vector and initialize the blosc2 superchunk.
-
template<typename T>
inline ImageChannel(Enum::Compression compression, const std::span<T> imageData, const Enum::ChannelIDInfo channelID, const int32_t width, const int32_t height, const float xcoord, const float ycoord)# Take a reference to a decompressed image span and initialize the blosc2 superchunk.
-
template<typename T>
inline ImageChannel(Enum::Compression compression, const std::span<const T> imageData, const Enum::ChannelIDInfo channelID, const int32_t width, const int32_t height, const float xcoord, const float ycoord)# Take a reference to a decompressed image span and initialize the blosc2 superchunk.
Public Members
-
Enum::Compression m_Compression = Enum::Compression::Raw#
This does not indicate the compression method of the channel in memory but rather the compression method it writes the PhotoshopFile with
-
Enum::ChannelIDInfo m_ChannelID = {Enum::ChannelID::Red, 1}#
Information about what channel this actually is.
-
uint64_t m_OrigByteSize = 0u#
The size of the original (uncompressed) data in bytes.
Public Static Attributes
-
static const uint64_t m_ChunkSize = 1024 * 1024 * 8#
The size of each sub-chunk in the super-chunk. For more information about what a chunk and super-chunk is please refer to the c-blosc2 documentation. Defaults to 8MB
-
inline int32_t getWidth() const#