Make more NAPS2.Images classes internal

This commit is contained in:
Ben Olden-Cooligan 2024-04-07 17:09:22 -07:00
parent 8543621317
commit ec70a7c017
52 changed files with 62 additions and 54 deletions

View File

@ -5,7 +5,7 @@ using NAPS2.Images.Bitwise;
namespace NAPS2.Images.Gdi;
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
public class GdiImageLockState : ImageLockState
internal class GdiImageLockState : ImageLockState
{
public static GdiImageLockState Create(Bitmap bitmap, LockMode lockMode, out BitwiseImageData imageData)
{

View File

@ -5,7 +5,7 @@ using System.Drawing.Imaging;
namespace NAPS2.Images.Gdi;
[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
public class GdiImageTransformer : AbstractImageTransformer<GdiImage>
internal class GdiImageTransformer : AbstractImageTransformer<GdiImage>
{
public GdiImageTransformer(ImageContext imageContext) : base(imageContext)
{

View File

@ -59,7 +59,7 @@ public class GtkImage : IMemoryImage
}
// TODO: Should we implement some kind of actual locking?
public class GtkImageLockState : ImageLockState
internal class GtkImageLockState : ImageLockState
{
public override void Dispose()
{

View File

@ -4,7 +4,7 @@ using NAPS2.Images.Bitwise;
namespace NAPS2.Images.Gtk;
public class GtkImageTransformer : AbstractImageTransformer<GtkImage>
internal class GtkImageTransformer : AbstractImageTransformer<GtkImage>
{
public GtkImageTransformer(ImageContext imageContext) : base(imageContext)
{

View File

@ -87,7 +87,7 @@ public class ImageSharpImage : IMemoryImage
return new ImageSharpImageLockState(memoryHandle);
}
public class ImageSharpImageLockState : ImageLockState
internal class ImageSharpImageLockState : ImageLockState
{
private readonly MemoryHandle _memoryHandle;

View File

@ -5,7 +5,7 @@ using SixLabors.ImageSharp.Processing;
namespace NAPS2.Images.ImageSharp;
public class ImageSharpImageTransformer : AbstractImageTransformer<ImageSharpImage>
internal class ImageSharpImageTransformer : AbstractImageTransformer<ImageSharpImage>
{
public ImageSharpImageTransformer(ImageContext imageContext) : base(imageContext)
{

View File

@ -4,7 +4,7 @@ namespace NAPS2.Images.Mac;
/// Building xamarin-mac and monomac on different platforms can mean dealing with different floating point types.
/// This class allows minimizing conditional compilation at the target site.
/// </summary>
public static class FloatHelper
internal static class FloatHelper
{
#if MONOMAC
public static float ToFloat(this float value)

View File

@ -109,7 +109,7 @@ public class MacImage : IMemoryImage
}
// TODO: Should we implement some kind of actual locking?
public class MacImageLockState : ImageLockState
internal class MacImageLockState : ImageLockState
{
public override void Dispose()
{

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Mac;
public class MacImageTransformer : AbstractImageTransformer<MacImage>
internal class MacImageTransformer : AbstractImageTransformer<MacImage>
{
public MacImageTransformer(ImageContext imageContext) : base(imageContext)
{

View File

@ -2,7 +2,7 @@ using NAPS2.Util;
namespace NAPS2.Images.Mac;
public class MacTiffWriter : ITiffWriter
internal class MacTiffWriter : ITiffWriter
{
public bool SaveTiff(IList<IMemoryImage> images, string path,
TiffCompressionType compression = TiffCompressionType.Auto, ProgressHandler progress = default)

View File

@ -4,7 +4,7 @@ using System.Windows.Media.Imaging;
namespace NAPS2.Images.Wpf;
public class WpfImageTransformer : AbstractImageTransformer<WpfImage>
internal class WpfImageTransformer : AbstractImageTransformer<WpfImage>
{
public WpfImageTransformer(ImageContext imageContext) : base(imageContext)
{

View File

@ -4,7 +4,7 @@ namespace NAPS2.Images.Bitwise;
/// Runs a bilateral filter operation, which reduces noise without losing edges or fine details.
/// https://en.wikipedia.org/wiki/Bilateral_filter
/// </summary>
public class BilateralFilterOp : BinaryBitwiseImageOp
internal class BilateralFilterOp : BinaryBitwiseImageOp
{
// The color distance (in the 0-255 range) at which pixels are weighted to 0.
// The weight linearly scales up as the color distance approaches 0.

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public abstract class BinaryBitwiseImageOp : BitwiseImageOp
internal abstract class BinaryBitwiseImageOp : BitwiseImageOp
{
public void Perform(IMemoryImage src, IMemoryImage dst)
{

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class BitPixelReader : IDisposable
internal class BitPixelReader : IDisposable
{
private const int THRESHOLD = 140 * 1000;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class BitwiseImageOp
internal class BitwiseImageOp
{
public const int R_MULT = 299;
public const int G_MULT = 587;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public static class BitwisePrimitives
internal static class BitwisePrimitives
{
public static unsafe void Invert(BitwiseImageData data, int partStart = -1, int partEnd = -1)
{

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class BlankDetectionImageOp : UnaryBitwiseImageOp
internal class BlankDetectionImageOp : UnaryBitwiseImageOp
{
// If the pixel value (0-255) >= white_threshold, then it counts as a white pixel.
private const int WHITE_THRESHOLD_MIN = 1;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class BrightnessBitwiseImageOp : UnaryBitwiseImageOp
internal class BrightnessBitwiseImageOp : UnaryBitwiseImageOp
{
private readonly float _brightnessAdjusted;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public enum ColorChannel
internal enum ColorChannel
{
All,
Red,

View File

@ -9,7 +9,7 @@ namespace NAPS2.Images.Bitwise;
/// be calibrated independently. Of course that means this correction must happen before deskew or anything else that
/// can combine values across columns.
/// </summary>
public class ColumnColorOp : UnaryBitwiseImageOp
internal class ColumnColorOp : UnaryBitwiseImageOp
{
/// <summary>
/// Performs this operation including pre-processing steps.

View File

@ -3,7 +3,7 @@ namespace NAPS2.Images.Bitwise;
/// <summary>
/// Performs pre-processing for the ColumnColorOp.
/// </summary>
public class ColumnColorPreOp : UnaryBitwiseImageOp
internal class ColumnColorPreOp : UnaryBitwiseImageOp
{
private const double COL_IGNORE_TOP_AND_BOTTOM = 0.02;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class ContrastBitwiseImageOp : UnaryBitwiseImageOp
internal class ContrastBitwiseImageOp : UnaryBitwiseImageOp
{
private readonly float _contrastAdjusted;
private readonly float _offset;

View File

@ -1,7 +1,7 @@
namespace NAPS2.Images.Bitwise;
// TODO: Need to double check callers set resolution when needed
public class CopyBitwiseImageOp : BinaryBitwiseImageOp
internal class CopyBitwiseImageOp : BinaryBitwiseImageOp
{
// TODO: Consider requiring an explicit DiscardAlpha parameter

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class DecolorBitwiseImageOp : UnaryBitwiseImageOp
internal class DecolorBitwiseImageOp : UnaryBitwiseImageOp
{
private readonly bool _blackAndWhite;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class FillColorImageOp : UnaryBitwiseImageOp
internal class FillColorImageOp : UnaryBitwiseImageOp
{
public static FillColorImageOp Black => new(0, 0, 0, 255);
public static FillColorImageOp White => new(255, 255, 255, 255);

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class HueShiftBitwiseImageOp : UnaryBitwiseImageOp
internal class HueShiftBitwiseImageOp : UnaryBitwiseImageOp
{
private readonly float _shiftAdjusted;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class LogicalPixelFormatOp : UnaryBitwiseImageOp
internal class LogicalPixelFormatOp : UnaryBitwiseImageOp
{
public ImagePixelFormat LogicalPixelFormat { get; private set; }

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class RgbPixelReader : IDisposable
internal class RgbPixelReader : IDisposable
{
private readonly ImageLockState _lock;
private readonly BitwiseImageData _data;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class RmseBitwiseImageOp : BinaryBitwiseImageOp
internal class RmseBitwiseImageOp : BinaryBitwiseImageOp
{
protected override LockMode SrcLockMode => LockMode.ReadOnly;
protected override LockMode DstLockMode => LockMode.ReadOnly;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class SaturationBitwiseImageOp : UnaryBitwiseImageOp
internal class SaturationBitwiseImageOp : UnaryBitwiseImageOp
{
private readonly float _saturationAdjusted;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class SharpenBitwiseImageOp : BinaryBitwiseImageOp
internal class SharpenBitwiseImageOp : BinaryBitwiseImageOp
{
private readonly float _sharpness;

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public abstract class UnaryBitwiseImageOp : BitwiseImageOp
internal abstract class UnaryBitwiseImageOp : BitwiseImageOp
{
public void Perform(IMemoryImage image)
{

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Bitwise;
public class UnmultiplyAlphaOp : UnaryBitwiseImageOp
internal class UnmultiplyAlphaOp : UnaryBitwiseImageOp
{
protected override void PerformCore(BitwiseImageData data, int partStart, int partEnd)
{

View File

@ -3,7 +3,7 @@ namespace NAPS2.Images.Bitwise;
/// <summary>
/// Corrects images with poor calibration for white/black values.
/// </summary>
public class WhiteBlackPointOp : UnaryBitwiseImageOp
internal class WhiteBlackPointOp : UnaryBitwiseImageOp
{
// When we've identified the block of pixel values that we consider white (or black),
// this is the percentile (counting from the mid levels) at which we set the

View File

@ -3,7 +3,7 @@ namespace NAPS2.Images.Bitwise;
/// <summary>
/// Performs pre-processing for the WhiteBlackPointOp.
/// </summary>
public class WhiteBlackPointPreOp : UnaryBitwiseImageOp
internal class WhiteBlackPointPreOp : UnaryBitwiseImageOp
{
public WhiteBlackPointPreOp(CorrectionMode mode)
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.Images.Bitwise;
namespace NAPS2.Images;
public struct BitwiseImageData
{

View File

@ -1,6 +1,6 @@
using System.Globalization;
namespace NAPS2.Images.Storage;
namespace NAPS2.Images;
public class FileStorageManager : IDisposable
{

View File

@ -1,8 +1,7 @@
namespace NAPS2.Images.Storage;
namespace NAPS2.Images;
/// <summary>
/// Base type for image storage, which can be a normal in-memory image (see IMemoryImage) or an image stored on the
/// filesystem (see ImageFileStorage).
/// Base type for image storage, which can be a normal in-memory image or an image stored on the filesystem.
/// </summary>
public interface IImageStorage : IDisposable
{

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images;
public interface IPdfRenderer
internal interface IPdfRenderer
{
IEnumerable<IMemoryImage> Render(ImageContext imageContext, string path, PdfRenderSize renderSize, string? password = null);

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images;
public interface IPdfRendererProvider
internal interface IPdfRendererProvider
{
IPdfRenderer PdfRenderer { get; }
}

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images.Storage;
namespace NAPS2.Images;
public class ImageFileStorage : IImageStorage
internal class ImageFileStorage : IImageStorage
{
private bool _disposed;

View File

@ -1,4 +1,4 @@
namespace NAPS2.Images.Storage;
namespace NAPS2.Images;
/// <summary>
/// A special type of image storage that stores an image encoded as an in-memory PNG/JPEG/PDF stream. Normally in-memory
@ -6,7 +6,7 @@
/// serialization use cases where we don't know yet if the image will be stored in-memory or on disk. And for PDFs
/// this is the only option for in-memory storage.
/// </summary>
public class ImageMemoryStorage : IImageStorage
internal class ImageMemoryStorage : IImageStorage
{
public ImageMemoryStorage(MemoryStream stream, string typeHint)
{

View File

@ -29,6 +29,15 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>NAPS2.Sdk</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>NAPS2.Sdk.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>NAPS2.Lib.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>NAPS2.Lib</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>NAPS2.Images.Gdi</_Parameter1>
</AssemblyAttribute>

View File

@ -1,6 +1,6 @@
namespace NAPS2.Images;
public class PdfRenderSize
internal class PdfRenderSize
{
public static readonly PdfRenderSize Default = FromDpi(300);

View File

@ -1,4 +1,4 @@
namespace NAPS2.Images.Bitwise;
namespace NAPS2.Images;
public class PixelInfo
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.Images.Bitwise;
namespace NAPS2.Images;
public class SubPixelType
{

View File

@ -3,7 +3,7 @@ using NAPS2.Util;
namespace NAPS2.Images.Transforms;
public abstract class AbstractImageTransformer<TImage> where TImage : IMemoryImage
internal abstract class AbstractImageTransformer<TImage> where TImage : IMemoryImage
{
protected AbstractImageTransformer(ImageContext imageContext)
{

View File

@ -22,6 +22,7 @@
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Include="Eto.Platform.Windows" Version="2.8.3" />
<PackageReference Include="Polyfill" Version="4.2.0" />
</ItemGroup>
<ItemGroup>

View File

@ -36,11 +36,11 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Include="Grpc.Tools" Version="2.62.0" PrivateAssets="all" />
<PackageReference Include="IsExternalInit" Version="1.0.3" />
<PackageReference Include="MimeKitLite" Version="4.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="Polyfill" Version="4.2.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
</ItemGroup>

View File

@ -25,10 +25,10 @@
<PackageReference Include="NAPS2.Pdfium.Binaries" Version="1.1.0" />
<PackageReference Include="NAPS2.Tesseract.Binaries" Version="1.2.0" />
<PackageReference Include="IsExternalInit" Version="1.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="PdfAValidator" Version="2.1.109" />
<PackageReference Include="Polyfill" Version="4.2.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" PrivateAssets="all" />

View File

@ -8,5 +8,5 @@ public record ImageMetadata(bool Lossless, PageSize? PageSize)
/// <summary>
/// A default set of metadata suitable for test images. Real use cases should be explicit and not use this default value.
/// </summary>
public static readonly ImageMetadata DefaultForTesting = new(false, null);
internal static readonly ImageMetadata DefaultForTesting = new(false, null);
}

View File

@ -2,7 +2,6 @@
<ItemGroup>
<Using Include="NAPS2.Images" />
<Using Include="NAPS2.Images.Storage" />
<Using Include="NAPS2.Images.Transforms" />
</ItemGroup>