Add method for merging layers that are at the same PositionZ

This commit is contained in:
tslater2006
2021-10-28 15:29:52 -05:00
parent 55ecd25683
commit b658c0e2f6
+17
View File
@@ -623,6 +623,23 @@ namespace UVtools.Core
return layers;
}
public Mat GetMergedMatForLayerAtIndex(uint startIndex)
{
/* This operates backwards because GetSamePositionedLayers returns the highest layer index with the same postion z, not the lowest */
var startLayer = this[startIndex];
Mat layerMat = startLayer.LayerMat;
for (var curIndex = startIndex + 1; curIndex < LayerCount && (this[curIndex].PositionZ == startLayer.PositionZ); curIndex++)
{
var nextLayer = this[curIndex].LayerMat;
CvInvoke.BitwiseOr(nextLayer, layerMat, layerMat);
nextLayer.Dispose();
}
return layerMat;
}
public Rectangle GetBoundingRectangle(OperationProgress progress = null)
{
if (!_boundingRectangle.IsEmpty || LayerCount == 0 || this[0] is null) return _boundingRectangle;