Skip to content

Commit

Permalink
Upgrade to .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpainter committed Apr 18, 2023
1 parent e4e64e9 commit e5c0b0b
Show file tree
Hide file tree
Showing 57 changed files with 96 additions and 149 deletions.
4 changes: 1 addition & 3 deletions Sanchez.Processing/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using SixLabors.ImageSharp;

namespace Sanchez.Processing.Extensions;
namespace Sanchez.Processing.Extensions;

public static class ColorExtensions
{
Expand Down
6 changes: 1 addition & 5 deletions Sanchez.Processing/Extensions/Images/BackgroundExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.Extensions.Images;
namespace Sanchez.Processing.Extensions.Images;

public static class BackgroundExtensions
{
Expand Down
3 changes: 0 additions & 3 deletions Sanchez.Processing/Extensions/Images/BorderCropExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Serilog;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.Extensions.Images;

Expand Down
6 changes: 1 addition & 5 deletions Sanchez.Processing/Extensions/Images/DrawImageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.Extensions.Images;
namespace Sanchez.Processing.Extensions.Images;

public static class DrawImageExtensions
{
Expand Down
5 changes: 1 addition & 4 deletions Sanchez.Processing/Extensions/Images/HistogramExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Normalization;
using SixLabors.ImageSharp.Processing.Processors.Normalization;

namespace Sanchez.Processing.Extensions.Images;

Expand Down
14 changes: 11 additions & 3 deletions Sanchez.Processing/Extensions/Images/ImageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using ExifLibrary;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.Extensions.Images;

Expand All @@ -24,8 +22,18 @@ public static async Task SaveWithExifAsync(this Image<Rgba32> image, string path

// Save image, increasing JPEG quality
var encoder = image.DetectEncoder(path);
if (encoder is JpegEncoder jpegEncoder) jpegEncoder.Quality = 95;

if (encoder is JpegEncoder jpegEncoder)
{
encoder = new JpegEncoder
{
Quality = 95,
Interleaved = jpegEncoder.Interleaved,
ColorType = jpegEncoder.ColorType,
SkipMetadata = jpegEncoder.SkipMetadata
};
}

try
{
await image.SaveAsync(path, encoder, ct);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sanchez.Processing.Models;
using Sanchez.Processing.Models.Configuration;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.Extensions.Images;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Sanchez.Processing.ImageProcessing.Mask;
using Sanchez.Processing.Models;
using Sanchez.Processing.Models.Projections;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.Extensions.Images;

Expand Down
2 changes: 1 addition & 1 deletion Sanchez.Processing/Helpers/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static class PathHelper
/// </summary>
private static string GetApplicationPath()
{
var processFilename = Process.GetCurrentProcess().MainModule!.FileName;
var processFilename = Environment.ProcessPath;

// Determine correct location of directories relative to application, depending on whether we are running
// from a published executable or via dotnet.
Expand Down
2 changes: 1 addition & 1 deletion Sanchez.Processing/Helpers/ProgressBarFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static IProgressBar NewProgressBar(RenderOptions options, int maxTicks, s

public static ProgressBarOptions DefaultOptions()
{
return new()
return new ProgressBarOptions
{
ProgressCharacter = '─',
ProgressBarOnBottom = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Collections.ObjectModel;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Atmosphere;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Collections.ObjectModel;
using System.Numerics;
using Sanchez.Processing.Models;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Atmosphere;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Collections.Concurrent;
using System.Numerics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Crop;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Sanchez.Processing.Models.Angles;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Intensity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Sanchez.Processing.ImageProcessing.Intensity;
using Sanchez.Processing.Models.Angles;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Lookup;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Mask;
namespace Sanchez.Processing.ImageProcessing.Mask;

public static class RemoveBackgroundExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Numerics;
using Sanchez.Processing.Models;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Mask;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using Sanchez.Processing.Models;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Noise;

Expand Down
6 changes: 1 addition & 5 deletions Sanchez.Processing/ImageProcessing/Noise/NoiseExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Noise;
namespace Sanchez.Processing.ImageProcessing.Noise;

public static class NoiseExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Offset;
namespace Sanchez.Processing.ImageProcessing.Offset;

public static class OffsetExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using Sanchez.Processing.Models.Configuration;
using Sanchez.Processing.Models.Projections;
using Sanchez.Processing.Projections;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Projection;

Expand Down
9 changes: 2 additions & 7 deletions Sanchez.Processing/ImageProcessing/Tint/TintExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.ColorSpaces.Conversion;

namespace Sanchez.Processing.ImageProcessing.Tint;

public static class TintExtensions
{
private static readonly ColorSpaceConverter Converter = new(new ColorSpaceConverterOptions());

/// <summary>
/// Applies a tint to an image.
/// </summary>
public static void Tint(this Image<Rgba32> image, Color colour)
{
var tint = colour.ToPixel<Rgba32>();
var lightness = 2 * (1 - (Converter.ToHsl(tint).L * 2 - 1));
var lightness = 2 * (1 - (ColorSpaceConverter.ToHsl(tint).L * 2 - 1));

var operation = new TintRowOperation(tint, lightness);
image.Mutate(c => c.ProcessPixelRowsAsVector4(row => operation.Invoke(row)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Tint;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Sanchez.Processing.Models;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.ImageProcessing.Underlay;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Sanchez.Processing.Extensions.Images;
using Sanchez.Processing.Models;
using Sanchez.Processing.Projections;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.ImageProcessing.Underlay;

Expand Down
2 changes: 1 addition & 1 deletion Sanchez.Processing/Models/Angles/AngleRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public AngleRange(Angle start, Angle end) : this(start.Radians, end.Radians)
/// Unwraps a longitude range so the end angle is always greater than the start angle.
/// This is to simplify maths for projections which wrap around the standard -180 to 180 degrees.
/// </summary>
public AngleRange UnwrapLongitude() => End < Start ? new AngleRange(Start, End + Constants.Pi2) : this;
public AngleRange UnwrapLongitude() => End < Start ? this with { End = End + Constants.Pi2 } : this;

public AngleRange NormaliseLongitude() => new(Start.NormaliseLongitude(), End.NormaliseLongitude());

Expand Down
1 change: 0 additions & 1 deletion Sanchez.Processing/Models/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sanchez.Processing.Helpers;
using Sanchez.Processing.Models.Configuration;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.Models;

Expand Down
7 changes: 2 additions & 5 deletions Sanchez.Processing/Models/ImageBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Sanchez.Processing.Models;
namespace Sanchez.Processing.Models;

public class ImageBuffer
{
Expand All @@ -14,7 +11,7 @@ private ImageBuffer(Rgba32[] buffer, Size size)
Size = size;
}

public static ImageBuffer ToBuffer(Image<Rgba32> image) => new(GetBuffer(image), image.Size());
public static ImageBuffer ToBuffer(Image<Rgba32> image) => new(GetBuffer(image), image.Size);

private static Rgba32[] GetBuffer(Image<Rgba32> image)
{
Expand Down
3 changes: 0 additions & 3 deletions Sanchez.Processing/Models/Projections/Registration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Sanchez.Processing.Models.Configuration;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace Sanchez.Processing.Models.Projections;

Expand Down
3 changes: 1 addition & 2 deletions Sanchez.Processing/Models/RenderOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Sanchez.Processing.Models.Configuration;
using Sanchez.Processing.Models.Projections;
using SixLabors.ImageSharp;

namespace Sanchez.Processing.Models;

Expand Down Expand Up @@ -163,7 +162,7 @@ public bool MultipleTargets
/// <summary>
/// Whether to apply gaussian noise to target image.
/// </summary>
public bool Noise { get; set; }
public bool Noise { get; init; }

/// <summary>
/// Output image extension, based off <see cref="OutputFormat"/>.
Expand Down
1 change: 0 additions & 1 deletion Sanchez.Processing/Models/UnderlayProjectionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Sanchez.Processing.Models.Angles;
using Sanchez.Processing.Models.Configuration;
using Sanchez.Processing.Models.Projections;
using SixLabors.ImageSharp;

namespace Sanchez.Processing.Models;

Expand Down
8 changes: 4 additions & 4 deletions Sanchez.Processing/Projections/GeostationaryProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public static void ToScanningAngle(LatitudeCalculations latitudeCalculations, do
/// </summary>
public struct LatitudeCalculations
{
public double Rc { get; set; }
public double Rc { get; init; }
public double RcCosLatitude { get; set; }
public double CosLatitude { get; set; }
public double Sz { get; set; }
public double Sz2 { get; set; }
public double CosLatitude { get; init; }
public double Sz { get; init; }
public double Sz2 { get; init; }
public double RadiusRatioSz2 { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static void ToLatitudeLongitude(double scanningX, double scanningY, doubl
public static void ToLatitudeLongitude(
double scanningX, VerticalScanningCalculations verticalScanningCalculations, double satelliteLongitude, out double latitude, out double longitude)
{
var l0 = satelliteLongitude;
var satelliteHeight = verticalScanningCalculations.SatelliteHeight;

var cosX = Cos(scanningX);
Expand All @@ -80,7 +79,7 @@ public static void ToLatitudeLongitude(
var sz = rs * cosX * sinY;

latitude = Atan(RadiusEquatorSquared / RadiusPolarSquared * (sz / Sqrt((satelliteHeight - sx) * (satelliteHeight - sx) + sy * sy)));
longitude = (l0 - Atan(sy / (satelliteHeight - sx))).NormaliseLongitude();
longitude = (satelliteLongitude - Atan(sy / (satelliteHeight - sx))).NormaliseLongitude();
}
}

Expand All @@ -90,8 +89,8 @@ public static void ToLatitudeLongitude(
public struct VerticalScanningCalculations
{
public double T { get; set; }
public double CosY { get; set; }
public double SinY { get; set; }
public double CosY { get; init; }
public double SinY { get; init; }
public double C { get; set; }
public double SatelliteHeight { get; set; }
public double SatelliteHeight { get; init; }
}
Loading

0 comments on commit e5c0b0b

Please sign in to comment.