Skip to content

Commit c00f8d9

Browse files
committed
Allow reading of clip paths without a name and give them a numeric name that can be used by ImageMagick (#1814).
1 parent f541356 commit c00f8d9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Magick.NET.Core/Profiles/8Bim/EightBimProfile.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ public IReadOnlyList<IClipPath> ClipPaths
7474
{
7575
Initialize();
7676

77-
var clipPaths = new List<IClipPath>(_values.Count);
78-
foreach (var value in _values)
77+
var clipPathValues = _values
78+
.Where(value => value.Id > 1999 && value.Id < 2998)
79+
.ToList();
80+
81+
var clipPaths = new List<IClipPath>(clipPathValues.Count);
82+
for (var i = 0; i < clipPathValues.Count; i++)
7983
{
80-
var clipPath = CreateClipPath(value);
84+
var clipPath = CreateClipPath(clipPathValues[i], i);
8185
if (clipPath is not null)
8286
clipPaths.Add(clipPath);
8387
}
@@ -229,11 +233,8 @@ protected override void UpdateData()
229233
SetData(data);
230234
}
231235

232-
private ClipPath? CreateClipPath(IEightBimValue value)
236+
private ClipPath? CreateClipPath(IEightBimValue value, int index)
233237
{
234-
if (value.Name is null)
235-
return null;
236-
237238
var d = GetClipPath(value.ToByteArray());
238239
if (string.IsNullOrEmpty(d))
239240
return null;
@@ -254,7 +255,8 @@ protected override void UpdateData()
254255
XmlHelper.SetAttribute(path, "stroke-antialiasing", "false");
255256
XmlHelper.SetAttribute(path, "d", d);
256257

257-
return new ClipPath(value.Name, doc.CreateNavigator()!);
258+
var name = value.Name ?? $"#{index + 1}";
259+
return new ClipPath(name, doc.CreateNavigator()!);
258260
}
259261

260262
private IEightBimValue? FindValue(int id)

0 commit comments

Comments
 (0)