Skip to content

Commit 6b03bbf

Browse files
committed
Configurable PixImage functions throw proper exceptions
See: #42
1 parent a70e602 commit 6b03bbf

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/Aardvark.Base.Tensors.CSharp/PixImage/PixImage.cs

+23-8
Original file line numberDiff line numberDiff line change
@@ -1584,10 +1584,15 @@ public override PixImage RemappedPixImage(
15841584
ImageInterpolation ip = ImageInterpolation.Cubic
15851585
) => Remapped(xMap, xMap, ip);
15861586

1587-
public PixImage<T> Remapped(
1588-
Matrix<float> xMap, Matrix<float> yMap,
1589-
ImageInterpolation ip = ImageInterpolation.Cubic
1590-
) => new PixImage<T>(Format, s_remappedFun(Volume, xMap, yMap, ip));
1587+
public PixImage<T> Remapped(Matrix<float> xMap, Matrix<float> yMap, ImageInterpolation ip = ImageInterpolation.Cubic)
1588+
{
1589+
if (s_remappedFun == null)
1590+
{
1591+
throw new NotSupportedException($"No remapping function has been installed via PixImage<{(typeof(T).Name)}>.SetRemappedFun");
1592+
}
1593+
1594+
return new PixImage<T>(Format, s_remappedFun(Volume, xMap, yMap, ip));
1595+
}
15911596

15921597
private static Func<Volume<T>, Matrix<float>, Matrix<float>, ImageInterpolation, Volume<T>> s_remappedFun = null;
15931598

@@ -1618,10 +1623,15 @@ public override PixImage RotatedPixImage(
16181623
ImageInterpolation ip = ImageInterpolation.Cubic
16191624
) => Rotated(angleInRadiansCCW, resize, ip);
16201625

1621-
public PixImage<T> Rotated(
1622-
double angleInRadiansCCW, bool resize = true,
1623-
ImageInterpolation ip = ImageInterpolation.Cubic
1624-
) => new PixImage<T>(Format, s_rotatedFun(Volume, angleInRadiansCCW, resize, ip));
1626+
public PixImage<T> Rotated(double angleInRadiansCCW, bool resize = true, ImageInterpolation ip = ImageInterpolation.Cubic)
1627+
{
1628+
if (s_rotatedFun == null)
1629+
{
1630+
throw new NotSupportedException($"No rotating function has been installed via PixImage<{(typeof(T).Name)}>.SetRotatedFun");
1631+
}
1632+
1633+
return new PixImage<T>(Format, s_rotatedFun(Volume, angleInRadiansCCW, resize, ip));
1634+
}
16251635

16261636
private static Func<Volume<T>, double, bool, ImageInterpolation, Volume<T>> s_rotatedFun = null;
16271637

@@ -1640,6 +1650,11 @@ public PixImage<T> Scaled(
16401650
V2d scaleFactor,
16411651
ImageInterpolation ip = ImageInterpolation.Cubic)
16421652
{
1653+
if (s_scaledFun == null)
1654+
{
1655+
throw new NotSupportedException($"No scaling function has been installed via PixImage<{(typeof(T).Name)}>.SetScaledFun");
1656+
}
1657+
16431658
if (!(scaleFactor.X > 0.0 && scaleFactor.Y > 0.0)) throw new ArgumentOutOfRangeException(nameof(scaleFactor));
16441659

16451660
// SuperSample is only available for scale factors < 1; fall back to Cubic

0 commit comments

Comments
 (0)