diff --git a/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs b/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs
index d5f810708..b4ec49946 100644
--- a/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs
+++ b/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs
@@ -5,6 +5,8 @@
namespace ImageSharp.Formats
{
+ using System.Runtime.CompilerServices;
+
///
/// The Average filter uses the average of the two neighboring pixels (left and above) to predict
/// the value of a pixel.
@@ -19,6 +21,7 @@ namespace ImageSharp.Formats
/// The previous scanline.
/// The number of bytes per scanline
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode(byte[] scanline, byte[] previousScanline, int bytesPerScanline, int bytesPerPixel)
{
// Average(x) + floor((Raw(x-bpp)+Prior(x))/2)
@@ -42,6 +45,7 @@ namespace ImageSharp.Formats
/// The previous scanline.
/// The filtered scanline result.
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(byte[] scanline, byte[] previousScanline, byte[] result, int bytesPerPixel)
{
// Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2)
@@ -67,6 +71,7 @@ namespace ImageSharp.Formats
/// The left byte
/// The above byte
/// The
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int Average(byte left, byte above)
{
return (left + above) >> 1;
diff --git a/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs b/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs
index e5787a944..5abd89296 100644
--- a/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs
+++ b/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs
@@ -6,6 +6,7 @@
namespace ImageSharp.Formats
{
using System;
+ using System.Runtime.CompilerServices;
///
/// The None filter, the scanline is transmitted unmodified; it is only necessary to
@@ -19,6 +20,7 @@ namespace ImageSharp.Formats
///
/// The scanline to decode
/// The
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte[] Decode(byte[] scanline)
{
// No change required.
@@ -30,6 +32,7 @@ namespace ImageSharp.Formats
///
/// The scanline to encode
/// The filtered scanline result.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(byte[] scanline, byte[] result)
{
// Insert a byte before the data.
diff --git a/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs b/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs
index ff208f3d7..a43d4f080 100644
--- a/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs
+++ b/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs
@@ -6,6 +6,7 @@
namespace ImageSharp.Formats
{
using System;
+ using System.Runtime.CompilerServices;
///
/// The Paeth filter computes a simple linear function of the three neighboring pixels (left, above, upper left),
@@ -22,6 +23,7 @@ namespace ImageSharp.Formats
/// The previous scanline.
/// The number of bytes per scanline
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode(byte[] scanline, byte[] previousScanline, int bytesPerScanline, int bytesPerPixel)
{
// Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp))
@@ -46,6 +48,7 @@ namespace ImageSharp.Formats
/// The previous scanline.
/// The filtered scanline result.
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(byte[] scanline, byte[] previousScanline, byte[] result, int bytesPerPixel)
{
// Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp))
@@ -76,6 +79,7 @@ namespace ImageSharp.Formats
///
/// The .
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static byte PaethPredicator(byte left, byte above, byte upperLeft)
{
int p = left + above - upperLeft;
diff --git a/src/ImageSharp.Formats.Png/Filters/SubFilter.cs b/src/ImageSharp.Formats.Png/Filters/SubFilter.cs
index 65e86f4f1..4610ed0ae 100644
--- a/src/ImageSharp.Formats.Png/Filters/SubFilter.cs
+++ b/src/ImageSharp.Formats.Png/Filters/SubFilter.cs
@@ -5,6 +5,8 @@
namespace ImageSharp.Formats
{
+ using System.Runtime.CompilerServices;
+
///
/// The Sub filter transmits the difference between each byte and the value of the corresponding byte
/// of the prior pixel.
@@ -18,6 +20,7 @@ namespace ImageSharp.Formats
/// The scanline to decode
/// The number of bytes per scanline
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode(byte[] scanline, int bytesPerScanline, int bytesPerPixel)
{
// Sub(x) + Raw(x-bpp)
@@ -37,6 +40,7 @@ namespace ImageSharp.Formats
/// The scanline to encode
/// The filtered scanline result.
/// The bytes per pixel.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(byte[] scanline, byte[] result, int bytesPerPixel)
{
// Sub(x) = Raw(x) - Raw(x-bpp)
diff --git a/src/ImageSharp.Formats.Png/Filters/UpFilter.cs b/src/ImageSharp.Formats.Png/Filters/UpFilter.cs
index 036862ddc..525f50d0f 100644
--- a/src/ImageSharp.Formats.Png/Filters/UpFilter.cs
+++ b/src/ImageSharp.Formats.Png/Filters/UpFilter.cs
@@ -5,6 +5,8 @@
namespace ImageSharp.Formats
{
+ using System.Runtime.CompilerServices;
+
///
/// The Up filter is just like the Sub filter except that the pixel immediately above the current pixel,
/// rather than just to its left, is used as the predictor.
@@ -18,6 +20,7 @@ namespace ImageSharp.Formats
/// The scanline to decode
/// The previous scanline.
/// The number of bytes per scanline
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode(byte[] scanline, byte[] previousScanline, int bytesPerScanline)
{
// Up(x) + Prior(x)
@@ -39,6 +42,7 @@ namespace ImageSharp.Formats
/// The scanline to encode
/// The previous scanline.
/// The filtered scanline result.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Encode(byte[] scanline, byte[] previousScanline, byte[] result)
{
// Up(x) = Raw(x) - Prior(x)