Skip to content

Commit

Permalink
Renamed Map to Remap.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Aug 11, 2024
1 parent b52a4fd commit ac0b36f
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 154 deletions.
34 changes: 17 additions & 17 deletions src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1995,23 +1995,6 @@ public partial interface IMagickImage : IDisposable
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Magnify();

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Map(IMagickImage image);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Map(IMagickImage image, IQuantizeSettings settings);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
Expand Down Expand Up @@ -2566,6 +2549,23 @@ public partial interface IMagickImage : IDisposable
/// <param name="region">The mask region.</param>
void RegionMask(IMagickGeometry region);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Remap(IMagickImage image);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Remap(IMagickImage image, IQuantizeSettings settings);

/// <summary>
/// Removes the artifact with the specified name.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions src/Magick.NET.Core/IMagickImageCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ public partial interface IMagickImageCollection : IDisposable
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
Task ReadAsync(string fileName, MagickFormat format, CancellationToken cancellationToken);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Remap(IMagickImage image);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Remap(IMagickImage image, IQuantizeSettings settings);

/// <summary>
/// Resets the page property of every image in the collection.
/// </summary>
Expand Down
15 changes: 0 additions & 15 deletions src/Magick.NET.Core/IMagickImageCollection{TQuantumType}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,6 @@ public partial interface IMagickImageCollection<TQuantumType> : IMagickImageColl
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickImage<TQuantumType> Fx(string expression, Channels channels);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Map(IMagickImage<TQuantumType> image);

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Map(IMagickImage<TQuantumType> image, IQuantizeSettings settings);

/// <summary>
/// Merge all layers onto a canvas just large enough to hold all the actual images. The virtual
/// canvas of the first image is preserved but otherwise ignored.
Expand Down
34 changes: 17 additions & 17 deletions src/Magick.NET.Core/IMagickImage{TQuantumType}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,6 @@ public partial interface IMagickImage<TQuantumType> : IMagickImage, IComparable<
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void LevelColors(IMagickColor<TQuantumType> blackColor, IMagickColor<TQuantumType> whiteColor, Channels channels);

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Map(IEnumerable<IMagickColor<TQuantumType>> colors);

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Map(IEnumerable<IMagickColor<TQuantumType>> colors, IQuantizeSettings settings);

/// <summary>
/// Changes any pixel that matches target with the color defined by fill.
/// </summary>
Expand Down Expand Up @@ -609,6 +592,23 @@ public partial interface IMagickImage<TQuantumType> : IMagickImage, IComparable<
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Ping(string fileName, IMagickReadSettings<TQuantumType>? readSettings);

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Remap(IEnumerable<IMagickColor<TQuantumType>> colors);

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
IMagickErrorInfo Remap(IEnumerable<IMagickColor<TQuantumType>> colors, IQuantizeSettings settings);

/// <summary>
/// Changes the value of individual pixels based on the intensity of each pixel compared to a
/// random threshold. The result is a low-contrast, two color image.
Expand Down
126 changes: 63 additions & 63 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3824,69 +3824,6 @@ public void Lower(uint size)
public void Magnify()
=> _nativeInstance.Magnify();

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Map(IEnumerable<IMagickColor<QuantumType>> colors)
{
Throw.IfNull(nameof(colors), colors);

return Map(colors, new QuantizeSettings());
}

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Map(IEnumerable<IMagickColor<QuantumType>> colors, IQuantizeSettings settings)
{
Throw.IfNull(nameof(colors), colors);

var colorList = new List<IMagickColor<QuantumType>>(colors);
if (colorList.Count == 0)
throw new ArgumentException("Value cannot be empty.", nameof(colors));

using var images = new MagickImageCollection();
foreach (var color in colorList)
images.Add(new MagickImage(color, 1, 1));

using var image = images.AppendHorizontally();
return Map(image, settings);
}

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Map(IMagickImage image)
=> Map(image, new QuantizeSettings());

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Map(IMagickImage image, IQuantizeSettings settings)
{
Throw.IfNull(nameof(image), image);
Throw.IfNull(nameof(settings), settings);

if (_nativeInstance.Map(image, settings))
return new MagickErrorInfo();

return CreateErrorInfo(this);
}

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
Expand Down Expand Up @@ -5088,6 +5025,69 @@ public void ReduceNoise(uint order)
public void RegionMask(IMagickGeometry geometry)
=> _nativeInstance.RegionMask(MagickRectangle.FromGeometry(geometry, this));

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Remap(IEnumerable<IMagickColor<QuantumType>> colors)
{
Throw.IfNull(nameof(colors), colors);

return Remap(colors, new QuantizeSettings());
}

/// <summary>
/// Remap image colors with closest color from the specified colors.
/// </summary>
/// <param name="colors">The colors to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Remap(IEnumerable<IMagickColor<QuantumType>> colors, IQuantizeSettings settings)
{
Throw.IfNull(nameof(colors), colors);

var colorList = new List<IMagickColor<QuantumType>>(colors);
if (colorList.Count == 0)
throw new ArgumentException("Value cannot be empty.", nameof(colors));

using var images = new MagickImageCollection();
foreach (var color in colorList)
images.Add(new MagickImage(color, 1, 1));

using var image = images.AppendHorizontally();
return Remap(image, settings);
}

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Remap(IMagickImage image)
=> Remap(image, new QuantizeSettings());

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <returns>The error informaton.</returns>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public IMagickErrorInfo Remap(IMagickImage image, IQuantizeSettings settings)
{
Throw.IfNull(nameof(image), image);
Throw.IfNull(nameof(settings), settings);

if (_nativeInstance.Map(image, settings))
return new MagickErrorInfo();

return CreateErrorInfo(this);
}

/// <summary>
/// Removes the artifact with the specified name.
/// </summary>
Expand Down
46 changes: 23 additions & 23 deletions src/Magick.NET/MagickImageCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,29 +610,6 @@ public void Insert(int index, IMagickImage<QuantumType> item)
public void Insert(int index, string fileName)
=> _images.Insert(index, new MagickImage(fileName));

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Map(IMagickImage<QuantumType> image)
=> Map(image, new QuantizeSettings());

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Map(IMagickImage<QuantumType> image, IQuantizeSettings settings)
{
Throw.IfNull(nameof(image), image);
Throw.IfNull(nameof(settings), settings);

using var imageAttacher = new TemporaryImageAttacher(_images);
_nativeInstance.Map(_images[0], settings, image);
}

/// <summary>
/// Merge all layers onto a canvas just large enough to hold all the actual images. The virtual
/// canvas of the first image is preserved but otherwise ignored.
Expand Down Expand Up @@ -860,6 +837,29 @@ public IMagickImage<QuantumType> Polynomial(double[] terms)
return MagickImage.Create(image, GetSettings());
}

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Remap(IMagickImage image)
=> Remap(image, new QuantizeSettings());

/// <summary>
/// Remap image colors with closest color from reference image.
/// </summary>
/// <param name="image">The image to use.</param>
/// <param name="settings">Quantize settings.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Remap(IMagickImage image, IQuantizeSettings settings)
{
Throw.IfNull(nameof(image), image);
Throw.IfNull(nameof(settings), settings);

using var imageAttacher = new TemporaryImageAttacher(_images);
_nativeInstance.Map(_images[0], settings, image);
}

/// <summary>
/// Quantize images (reduce number of colors).
/// </summary>
Expand Down
Loading

0 comments on commit ac0b36f

Please sign in to comment.