Base Layer Structure#
Note
This struct is not to be used directly but holds all the virtual base functions which all the other layers may use. It additionally defines the
Layer<T>::Params
struct which is expected to be passed into layer initialization for its subclassed types
-
template<typename T>
struct Layer# Base Struct for Layers of all types (Group, Image, [Adjustment], etc.) which includes the minimum to parse a generic layer type.
Subclassed by AdjustmentLayer< T >, ArtboardLayer< T >, GroupLayer< T >, ImageLayer< T >, SectionDividerLayer< T >, ShapeLayer< T >, SmartObjectLayer< T >, TextLayer< T >
Public Functions
-
inline Layer()#
-
Layer(const LayerRecord &layerRecord, ChannelImageData &channelImageData, const FileHeader &header)#
Initialize a Layer instance from the internal Photoshop File Format structures.
This constructor is responsible for creating a Layer object based on the information stored in the provided Photoshop File Format structures. It extracts relevant data from the LayerRecord, ChannelImageData, and FileHeader to set up the Layer.
- Parameters:
layerRecord – The LayerRecord containing information about the layer.
channelImageData – The ChannelImageData holding the image data.
header – The FileHeader providing overall file information.
-
virtual std::tuple<LayerRecord, ChannelImageData> toPhotoshop(Enum::ColorMode colorMode, const bool doCopy, const FileHeader &header)#
Function for creating a PhotoshopFile from the layer.
In the future, the intention is to make this a pure virtual function. However, due to the presence of multiple miscellaneous layers not yet implemented for the initial release, this function is provided. It generates a tuple containing LayerRecord and ChannelImageData based on the specified ColorMode, copying data if required, and using the provided FileHeader.
- Parameters:
colorMode – The desired ColorMode for the PhotoshopFile.
doCopy – A flag indicating whether to perform a copy of the layer data.
header – The FileHeader providing overall file information.
- Returns:
A tuple containing LayerRecord and ChannelImageData representing the layer in the PhotoshopFile.
-
std::vector<T> getMaskData(const bool doCopy = true)#
Extract the mask data as a vector, if doCopy is false the image data is freed and no longer usable.
-
virtual void setCompression(const Enum::Compression compCode)#
Changes the compression mode of all channels in this layer to the given compression mode.
-
virtual ~Layer() = default#
Public Members
-
std::string m_LayerName#
-
bool m_IsVisible#
Marks whether or not the layer is visible or not.
-
uint8_t m_Opacity#
0 - 255 despite the appearance being 0-100 in photoshop
-
uint32_t m_Width#
-
uint32_t m_Height#
-
float m_CenterX#
-
float m_CenterY#
-
struct Params#
Layer Parameters for initialization of a generic layer type. It provides sensible defaults so only what is needed needs to be overridden
Public Members
-
std::optional<std::vector<T>> layerMask = std::nullopt#
Optional Layer Mask parameter, if none is specified there is no mask. This image data must have the same size as the layer itself
-
Enum::BlendMode blendMode = Enum::BlendMode::Normal#
The Layers Blend Mode, all available blend modes are valid except for ‘Passthrough’ on non-group layers.
-
int32_t posX = 0#
The X Center coordinate, 0 indicates that the image is centered around the document, a negative value moves the layer to the left.
-
int32_t posY = 0#
The Y Center coordinate, 0 indicates that the image is centered around the document, a negative value moves the layer to the top.
-
uint32_t width = 0u#
The width of the layer, this value must be passed explicitly as we do not deduce this from the Image Data itself.
-
uint32_t height = 0u#
The height of the layer, this value must be passed explicitly as we do not deduce this from the Image Data itself.
-
uint8_t opacity = 255u#
The Layer opacity, the value displayed by Photoshop will be this value / 2.55 so 255 corresponds to 100% while 128 would correspond to ~50%
-
Enum::Compression compression = Enum::Compression::ZipPrediction#
-
std::optional<std::vector<T>> layerMask = std::nullopt#
-
inline Layer()#