Skip to content

Commit

Permalink
Refactor how to set the scene values in the native library.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Sep 28, 2024
1 parent e7cfa17 commit fd8b185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
2 changes: 0 additions & 2 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7163,8 +7163,6 @@ private MagickReadSettings CreateReadSettings(IMagickReadSettings<QuantumType>?
else
newReadSettings = new MagickReadSettings(readSettings);

newReadSettings.ForceSingleFrame();

return newReadSettings;
}

Expand Down
25 changes: 5 additions & 20 deletions src/Magick.NET/Settings/MagickReadSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ public bool UseMonochrome
/// </summary>
public uint? Width { get; set; }

internal void ForceSingleFrame()
{
FrameCount = 1;
ApplyFrame();
}

private static string GetDefineKey(IDefine define)
{
if (define.Format == MagickFormat.Unknown)
Expand All @@ -139,19 +133,6 @@ private static string GetDefineKey(IDefine define)
return EnumHelper.GetName(define.Format) + ":" + define.Name;
}

private string? GetScenes()
{
if (!FrameIndex.HasValue && (!FrameCount.HasValue || FrameCount.Value == 1))
return null;

if (FrameIndex.HasValue && (!FrameCount.HasValue || FrameCount.Value == 1))
return FrameIndex.Value.ToString(CultureInfo.InvariantCulture);

var frame = FrameIndex ?? 0;
var count = FrameCount ?? 1;
return string.Format(CultureInfo.InvariantCulture, "{0}-{1}", frame, frame + count);
}

private void ApplyDefines()
{
if (Defines is null)
Expand All @@ -178,9 +159,13 @@ private void ApplyFrame()
if (!FrameIndex.HasValue && !FrameCount.HasValue)
return;

Scenes = GetScenes();
Scene = FrameIndex ?? 0;
NumberScenes = FrameCount ?? 1;

if (FrameIndex.HasValue && (!FrameCount.HasValue || FrameCount.Value == 1))
Scenes = FrameIndex.Value.ToString(CultureInfo.InvariantCulture);
else
Scenes = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", Scene, Scene + NumberScenes);
}

private void Copy(IMagickReadSettings<QuantumType> settings)
Expand Down

0 comments on commit fd8b185

Please sign in to comment.