Section Divider Structure#
The Photoshop File format stores this layer to mark the end of a grouped section as outlined below. This Layer is created automatically on conversion and creating one manually should not be done
Group
.…
SectionDivider
-
template<typename T>
struct SectionDividerLayer : public Layer<T># This struct holds no data, this is just how photoshop stores the end of a group as it doesn’t really have a concept of nesting otherwise. These are only created on write and not actually stored in the layer hierarchy of the file as we use nested layers to denote hierarchies.
Masks
-
inline bool has_mask() const noexcept#
Checks whether the layer has a pixel mask.
- Returns:
trueif a mask is present, otherwisefalse.
-
inline std::vector<T> get_mask() const#
Retrieves the mask channel data, if present.
If the layer does not have a mask, this function returns an empty vector.
The returned vector contains
mask_width() * mask_height()elements.
-
inline void get_mask(std::span<T> buffer) const#
Fills a preallocated buffer with the mask channel data, if present.
If no mask is present, the buffer remains unchanged.
- Parameters:
buffer – A preallocated buffer expected to have exactly
mask_width() * mask_height()elements.
-
inline void set_mask(std::span<const T> buffer, size_t width, size_t height)#
Sets the layer’s mask to the given buffer.
If no mask was previously held the inserted mask will be at the top-left of the canvas. Use
mask_positionto adjust this.- Parameters:
buffer – The image data for the mask, provided in scanline order.
width – The width of the new mask.
height – The height of the new mask.
- Throws:
std::invalid_argument – If the buffer size does not match the expected dimensions.
-
inline void set_mask(const LayeredFile<T> &document, std::span<const T> buffer, std::optional<size_t> width = std::nullopt, std::optional<size_t> height = std::nullopt)#
Sets the layer’s mask to the given buffer.
If the layer previously had a mask, the new mask will be centered at the same position.
If no mask was previously present, the new mask will be centered on the document.
- Parameters:
document – The file to which this mask layer belongs.
buffer – The image data for the mask, provided in scanline order. If
widthandheightare unspecified, the buffer must have exactlymask_width() * mask_height()elements. If no dimensions are specified and the layer previously had no mask, an exception is thrown.width – (Optional) The width of the new mask. Required if replacing with a differently sized mask.
height – (Optional) The height of the new mask. Required if replacing with a differently sized mask.
- Throws:
std::invalid_argument – If the buffer size does not match the expected dimensions.
std::runtime_error – If no mask existed and no explicit dimensions were provided.
-
inline void set_mask_compression(Enum::Compression _compcode) noexcept#
Set the masks write compression.
If
has_mask()evaluates to false this is a no-op.- Parameters:
_compcode – The compression codec to apply on-write.
-
inline Geometry::BoundingBox<double> mask_bbox() const#
Retrieves the bounding box of the mask, if present.
If no mask exists, this function returns a zero-sized bounding box.
- Returns:
The mask’s bounding box, or an empty bounding box if no mask is present.
-
inline size_t mask_width() const#
Retrieves the width of the mask, if present.
If no mask exists, this function returns zero
- Returns:
The mask’s width or zero if no mask exists
-
inline size_t mask_height() const#
Retrieves the height of the mask, if present.
If no mask exists, this function returns zero
- Returns:
The mask’s height or zero if no mask exists
-
inline Geometry::Point2D<double> mask_position() const#
Retrieves the position of the mask, defined as its center.
If no mask is present, this function returns
{-1.0, -1.0}.- Returns:
The center position of the mask, or
{-1.0, -1.0}if no mask exists.
-
inline void mask_position(Geometry::Point2D<double> position)#
Sets the center position of the mask.
If no mask is present, this function does nothing.
- Parameters:
position – The new center position of the mask.
-
inline bool mask_relative_to_layer()#
Checks whether the mask is relative to the layer.
- Returns:
trueif the mask is relative to the layer, otherwisefalse.
-
inline void mask_relative_to_layer(bool value)#
Sets whether the mask should be relative to the layer.
- Parameters:
value –
trueto make the mask relative to the layer, otherwisefalse.
-
inline bool mask_disabled()#
Checks whether the mask is disabled.
- Returns:
trueif the mask is disabled, otherwisefalse.
-
inline void mask_disabled(bool value)#
Enables or disables the mask.
- Parameters:
value –
trueto disable the mask, otherwisefalse.
-
inline uint8_t mask_default_color()#
Retrieves the mask’s default fill color.
- Returns:
The default mask color.
-
inline void mask_default_color(uint8_t value)#
Sets the mask’s default fill color.
- Parameters:
value – The new default color value.
-
inline std::optional<uint8_t> mask_density()#
Retrieves the mask density, if specified.
- Returns:
The mask density value, or an empty optional if unspecified.
-
inline void mask_density(uint8_t value)#
Sets the mask density.
- Parameters:
value – The new mask density.
-
inline void mask_density(std::optional<uint8_t> value)#
Sets the mask density, allowing for removal.
- Parameters:
value – An optional new mask density.
-
inline std::optional<float64_t> mask_feather()#
Retrieves the mask feathering amount, if specified.
- Returns:
The mask feather value, or an empty optional if unspecified.
-
inline void mask_feather(float64_t value)#
Sets the mask feathering amount.
- Parameters:
value – The new mask feather value.
-
inline void mask_feather(std::optional<float64_t> value)#
Public Types
-
using channel_type = std::unique_ptr<ImageChannel>#
Public Functions
-
SectionDividerLayer() = default#
-
inline virtual std::tuple<LayerRecord, ChannelImageData> to_photoshop() override#
Function for creating a PhotoshopFile compatible types from the layer.
This is part of the internal API and as a user you will likely never have to use this function.
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, and using the provided FileHeader.
- Returns:
A tuple containing LayerRecord and ChannelImageData representing the layer in the PhotoshopFile.
-
inline const std::string &name() const noexcept#
The layers’ name. Stored as a utf-8 string.
-
inline std::string &name() noexcept#
The layers’ name. Stored as a utf-8 string.
-
inline void name(const std::string &layer_name) noexcept#
The layers’ name. Stored as a utf-8 string.
-
inline Enum::BlendMode &blendmode() noexcept#
The blendmode of the layer, the
Passthroughblendmode is only valid for groups.
-
inline Enum::BlendMode blendmode() const noexcept#
The blendmode of the layer, the
Passthroughblendmode is only valid for groups.
-
inline void blendmode(Enum::BlendMode blend_mode) noexcept#
The blendmode of the layer, the
Passthroughblendmode is only valid for groups.
-
inline bool &locked() noexcept#
Whether the layers’ pixel values are locked. This is currently an all or nothing setting.
-
inline bool locked() const noexcept#
Whether the layers’ pixel values are locked. This is currently an all or nothing setting.
-
inline void locked(bool is_locked) noexcept#
Whether the layers’ pixel values are locked. This is currently an all or nothing setting.
-
inline bool &visible() noexcept#
Visibility toggle of the layer.
-
inline bool visible() const noexcept#
Visibility toggle of the layer.
-
inline void visible(bool is_visible) noexcept#
Visibility toggle of the layer.
-
inline float opacity() const noexcept#
The layers’ opacity.
In photoshop this is stored as a
uint8_tfrom 0-255 but access and write is in terms of a float for better consistency.
-
inline void opacity(float value) noexcept#
The layers’ opacity.
In photoshop this is stored as a
uint8_tfrom 0-255 but access and write is in terms of a float for better consistency.
-
inline virtual uint32_t width() const noexcept#
The layers’ width from 0 - 300,000.
-
inline virtual void width(uint32_t layer_width)#
The layers’ width from 0 - 300,000.
-
inline virtual uint32_t height() const noexcept#
The layers’ height from 0 - 300,000.
-
inline virtual void height(uint32_t layer_height)#
The layers’ height from 0 - 300,000.
-
inline virtual float center_x() const noexcept#
The layers’ x center coordinate
I.e. if the layer has the bounds { 200, 200 } - { 1000, 1000 } The center would be at { 600, 600 }
-
inline virtual void center_x(float x_coord) noexcept#
-
inline virtual float center_y() const noexcept#
The layers’ y center coordinate
I.e. if the layer has the bounds { 200, 200 } - { 1000, 1000 } The center would be at { 600, 600 }
-
inline virtual void center_y(float y_coord) noexcept#
-
inline float top_left_x() const noexcept#
Convenience function for accessing the top left x coordinate of a layer.
-
inline float top_left_y() const noexcept#
Convenience function for accessing the top left y coordinate of a layer.
-
inline Enum::ColorMode color_mode() const noexcept#
The color mode with which the file was created, only stored to allow better detection during channel access for e.g. image layers
-
inline virtual void set_write_compression(Enum::Compression _compcode)#
Set the write compression for all channels.
This has no effect on the in-memory compression of these channels but only on write. Setting this therefore has a near-zero runtime cost.
- Parameters:
_compcode – The new compression setting.
Public Static Attributes
-
static constexpr auto s_mask_index = Enum::ChannelIDInfo{Enum::ChannelID::UserSuppliedLayerMask, -2}#
Colormode independent mask index as Enum::ChannelIDInfo that may be used.
-
inline bool has_mask() const noexcept#