Skip to content

Commit

Permalink
Added MipmapCount to the DdsWriteDefines that will replace the Mipmap…
Browse files Browse the repository at this point in the history
…s property in the next major release.
  • Loading branch information
dlemstra committed Feb 7, 2024
1 parent 91a18cb commit dd30d8b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions src/Magick.NET/Formats/Dds/DdsWriteDefines.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using System;
using System.Collections.Generic;

namespace ImageMagick.Formats;
Expand Down Expand Up @@ -35,7 +36,17 @@ public MagickFormat Format
/// <summary>
/// Gets or sets the the number of mipmaps, zero will disable writing mipmaps (dds:mipmaps).
/// </summary>
public int? Mipmaps { get; set; }
[Obsolete($"This property will be removed in the next major release, use {nameof(MipmapCount)} instead.")]
public int? Mipmaps
{
get => MipmapCount;
set => MipmapCount = value;
}

/// <summary>
/// Gets or sets the the number of mipmaps, zero will disable writing mipmaps (dds:mipmaps).
/// </summary>
public int? MipmapCount { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the mipmaps should be created from the images in the collection (dds:mipmaps=fromlist).
Expand Down Expand Up @@ -70,8 +81,8 @@ public IEnumerable<IDefine> Defines

if (MipmapsFromCollection == true)
yield return new MagickDefine(Format, "mipmaps", "fromlist");
else if (Mipmaps.HasValue)
yield return new MagickDefine(Format, "mipmaps", Mipmaps.Value);
else if (MipmapCount.HasValue)
yield return new MagickDefine(Format, "mipmaps", MipmapCount.Value);

if (Raw.HasValue)
yield return new MagickDefine(Format, "raw", Raw.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ namespace Magick.NET.Tests;

public partial class DdsWriteDefinesTests
{
public class TheMipmapsProperty
public class TheMipmapCountProperty
{
[Fact]
public void ShouldSetTheDefine()
{
var defines = new DdsWriteDefines
{
Mipmaps = 2,
MipmapCount = 2,
};

using var image = new MagickImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ShouldSetTheDefine()
var defines = new DdsWriteDefines
{
MipmapsFromCollection = true,
Mipmaps = 4, // this is ignored
MipmapCount = 4, // this is ignored
};

using var image = new MagickImage();
Expand All @@ -32,7 +32,7 @@ public void ShouldBeIgnoredWhenSetToFalse()
var defines = new DdsWriteDefines
{
MipmapsFromCollection = false,
Mipmaps = 4,
MipmapCount = 4,
};

using var image = new MagickImage();
Expand Down

0 comments on commit dd30d8b

Please sign in to comment.