Skip to content

Commit

Permalink
[PixImage] Make naming of Create() parameters consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jun 20, 2024
1 parent a6f383a commit 37d3977
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Aardvark.Base.Tensors.CSharp/PixImage/PixImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,16 @@ private static void ToGray<T, Tv, R>(PixImage src, object dst, Func<Tv, R> toGra
// Helper class to create PixImage from given Type
private static class Dispatch
{
private delegate PixImage CreateDelegate(Col.Format format, long width, long height, long channels);
private delegate PixImage CreateArrayDelegate(Array data, Col.Format format, long width, long height, long channels);
private delegate PixImage CreateDelegate(Col.Format format, long sizeX, long sizeY, long channels);
private delegate PixImage CreateArrayDelegate(Array data, Col.Format format, long sizeX, long sizeY, long channels);

private static class CreateDispatcher
{
public static PixImage Create<T>(Col.Format format, long width, long height, long channels)
=> new PixImage<T>(format, width, height, channels);
public static PixImage Create<T>(Col.Format format, long sizeX, long sizeY, long channels)
=> new PixImage<T>(format, sizeX, sizeY, channels);

public static PixImage CreateArray<T>(Array data, Col.Format format, long width, long height, long channels)
=> new PixImage<T>(format, ((T[])data).CreateImageVolume(new V3l(width, height, channels)));
public static PixImage CreateArray<T>(Array data, Col.Format format, long sizeX, long sizeY, long channels)
=> new PixImage<T>(format, ((T[])data).CreateImageVolume(new V3l(sizeX, sizeY, channels)));
}

private const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
Expand All @@ -409,24 +409,24 @@ public static PixImage CreateArray<T>(Array data, Col.Format format, long width,
private static readonly MethodInfo s_createArrayMethod = typeof(CreateDispatcher).GetMethod(nameof(CreateDispatcher.CreateArray), flags);
private static readonly ConcurrentDictionary<Type, CreateArrayDelegate> s_createArrayDelegates = new();

public static PixImage Create(PixFormat format, long width, long height, long channels)
public static PixImage Create(PixFormat format, long sizeX, long sizeY, long channels)
{
var create = s_createDelegates.GetOrAdd(format.Type, t => {
var mi = s_createMethod.MakeGenericMethod(t);
return (CreateDelegate)Delegate.CreateDelegate(typeof(CreateDelegate), mi);
});

return create(format.Format, width, height, channels);
return create(format.Format, sizeX, sizeY, channels);
}

public static PixImage Create(Array array, Col.Format format, long width, long height, long channels)
public static PixImage Create(Array array, Col.Format format, long sizeX, long sizeY, long channels)
{
var create = s_createArrayDelegates.GetOrAdd(array.GetType().GetElementType(), t => {
var mi = s_createArrayMethod.MakeGenericMethod(t);
return (CreateArrayDelegate)Delegate.CreateDelegate(typeof(CreateArrayDelegate), mi);
});

return create(array, format, width, height, channels);
return create(array, format, sizeX, sizeY, channels);
}
}

Expand All @@ -436,17 +436,17 @@ public static PixImage Create(Array array, Col.Format format, long width, long h

#region Static Creator Functions

public static PixImage Create(PixFormat format, long sx, long sy, long ch)
=> Dispatch.Create(format, sx, sy, ch);
public static PixImage Create(PixFormat format, long sizeX, long sizeY, long channelCount)
=> Dispatch.Create(format, sizeX, sizeY, channelCount);

public static PixImage Create(PixFormat format, long sx, long sy)
=> Dispatch.Create(format, sx, sy, format.ChannelCount);
public static PixImage Create(PixFormat format, long sizeX, long sizeY)
=> Dispatch.Create(format, sizeX, sizeY, format.ChannelCount);

public static PixImage Create(Array array, Col.Format format, long sx, long sy, long ch)
=> Dispatch.Create(array, format, sx, sy, ch);
public static PixImage Create(Array array, Col.Format format, long sizeX, long sizeY, long channelCount)
=> Dispatch.Create(array, format, sizeX, sizeY, channelCount);

public static PixImage Create(Array array, Col.Format format, long sx, long sy)
=> Dispatch.Create(array, format, sx, sy, format.ChannelCount());
public static PixImage Create(Array array, Col.Format format, long sizeX, long sizeY)
=> Dispatch.Create(array, format, sizeX, sizeY, format.ChannelCount());

public static Volume<T> CreateVolume<T>(V3i size) => size.ToV3l().CreateImageVolume<T>();

Expand Down

0 comments on commit 37d3977

Please sign in to comment.