Skip to content

Commit

Permalink
Merge pull request #25 from askmeaboutlo0m/master
Browse files Browse the repository at this point in the history
Allow reading pass-through property of layers
  • Loading branch information
MolecularMatters committed Oct 16, 2023
2 parents 9f793c0 + 1ae7d32 commit 469fe1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Psd/PsdLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct Layer

uint32_t type; ///< The layer's type. Can be any of \ref layerType::Enum.
bool isVisible; ///< The layer's visibility.
bool isPassThrough; ///< If the layer is a pass-through group.
};

PSD_NAMESPACE_END
19 changes: 17 additions & 2 deletions src/Psd/PsdParseLayerMaskSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ namespace
layer->layerMask = nullptr;
layer->vectorMask = nullptr;
layer->type = layerType::ANY;
layer->isPassThrough = false;

layer->top = fileUtil::ReadFromFileBE<int32_t>(reader);
layer->left = fileUtil::ReadFromFileBE<int32_t>(reader);
Expand Down Expand Up @@ -705,8 +706,22 @@ namespace
{
layer->type = fileUtil::ReadFromFileBE<uint32_t>(reader);

// skip the rest of the data
reader.Skip(length - 4u);
// there may be another blend mode here to tell us if the group is pass-through
if(length >= 12u)
{
const uint32_t lsctKey = fileUtil::ReadFromFileBE<uint32_t>(reader);
const uint32_t modeKey = fileUtil::ReadFromFileBE<uint32_t>(reader);
if (lsctKey == util::Key<'8', 'B', 'I', 'M'>::VALUE && modeKey == util::Key<'p', 'a', 's', 's'>::VALUE)
{
layer->isPassThrough = true;
}
reader.Skip(length - 12u);
}
else
{
// skip the rest of the data
reader.Skip(length - 4u);
}
}
// read Unicode layer name
else if (key == util::Key<'l', 'u', 'n', 'i'>::VALUE)
Expand Down

0 comments on commit 469fe1f

Please sign in to comment.