diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs b/src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs
index dbe9035af..88aa8a3fe 100644
--- a/src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs
+++ b/src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs
@@ -47,7 +47,7 @@ namespace ImageSharp.Formats.Jpg
// Grab the decode bytes, use them and then set them
// back on the decoder.
- var decoderBytes = decoder.Bytes;
+ Bytes decoderBytes = decoder.Bytes;
byte c = decoderBytes.ReadByteStuffedByte(decoder.InputStream, out errorCode);
decoder.Bytes = decoderBytes;
@@ -84,7 +84,7 @@ namespace ImageSharp.Formats.Jpg
{
if (this.UnreadBits < t)
{
- var errorCode = this.EnsureNBits(t, decoder);
+ JpegDecoderCore.ErrorCodes errorCode = this.EnsureNBits(t, decoder);
if (errorCode != JpegDecoderCore.ErrorCodes.NoError)
{
throw new JpegDecoderCore.MissingFF00Exception();
diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
index 96e3f3071..a121a0bc2 100644
--- a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
@@ -226,6 +226,22 @@ namespace ImageSharp.Formats
stream.Flush();
}
+ ///
+ /// Writes data to "Define Quantization Tables" block for QuantIndex
+ ///
+ /// The "Define Quantization Tables" block
+ /// Offset in dqt
+ /// The quantization index
+ /// The quantazation table to copy data from
+ private static void WriteDataToDqt(byte[] dqt, ref int offset, QuantIndex i, ref Block8x8F q)
+ {
+ dqt[offset++] = (byte)i;
+ for (int j = 0; j < Block8x8F.ScalarCount; j++)
+ {
+ dqt[offset++] = (byte)q[j];
+ }
+ }
+
private static void InitQuantizationTable(int i, int scale, ref Block8x8F quant)
{
for (int j = 0; j < Block8x8F.ScalarCount; j++)
@@ -622,8 +638,8 @@ namespace ImageSharp.Formats
byte[] dqt = ArrayPool.Shared.Rent(dqtCount);
int offset = 0;
- JpegUtils.WriteDataToDqt(dqt, ref offset, QuantIndex.Luminance, ref this.luminanceQuantTable);
- JpegUtils.WriteDataToDqt(dqt, ref offset, QuantIndex.Chrominance, ref this.chrominanceQuantTable);
+ WriteDataToDqt(dqt, ref offset, QuantIndex.Luminance, ref this.luminanceQuantTable);
+ WriteDataToDqt(dqt, ref offset, QuantIndex.Chrominance, ref this.chrominanceQuantTable);
this.outputStream.Write(dqt, 0, dqtCount);
ArrayPool.Shared.Return(dqt);
@@ -782,7 +798,7 @@ namespace ImageSharp.Formats
// ReSharper disable once InconsistentNaming
float prevDCY = 0, prevDCCb = 0, prevDCCr = 0;
- using (var rgbBytes = new PixelArea(8, 8, ComponentOrder.XYZ, true))
+ using (PixelArea rgbBytes = new PixelArea(8, 8, ComponentOrder.XYZ, true))
{
for (int y = 0; y < pixels.Height; y += 16)
{
@@ -814,6 +830,7 @@ namespace ImageSharp.Formats
&temp2,
&onStackChrominanceQuantTable,
unzig.Data);
+
Block8x8F.Scale16X16To8X8(&b, crPtr);
prevDCCr = this.WriteBlock(
QuantIndex.Chrominance,
diff --git a/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs b/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
index fa2647751..7163af315 100644
--- a/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
+++ b/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
@@ -19,18 +19,10 @@ namespace ImageSharp.Formats.Jpg
///
/// The pixel type
///
- ///
- /// The input pixel acessor
- ///
- ///
- /// The destination
- ///
- ///
- /// Starting Y coord
- ///
- ///
- /// Starting X coord
- ///
+ /// The input pixel acessor
+ /// The destination
+ /// Starting Y coord
+ /// Starting X coord
public static void CopyRGBBytesStretchedTo(
this PixelAccessor pixels,
PixelArea dest,
@@ -47,12 +39,8 @@ namespace ImageSharp.Formats.Jpg
///
/// Copy an RGB value
///
- ///
- /// Source pointer
- ///
- ///
- /// Destination pointer
- ///
+ /// Source pointer
+ /// Destination pointer
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void CopyRgb(byte* source, byte* dest)
{
@@ -61,30 +49,6 @@ namespace ImageSharp.Formats.Jpg
*dest = *source; // B
}
- ///
- /// Writes data to "Define Quantization Tables" block for QuantIndex
- ///
- ///
- /// The "Define Quantization Tables" block
- ///
- ///
- /// Offset in dqt
- ///
- ///
- /// The quantization index
- ///
- ///
- /// The quantazation table to copy data from
- ///
- internal static void WriteDataToDqt(byte[] dqt, ref int offset, QuantIndex i, ref Block8x8F q)
- {
- dqt[offset++] = (byte)i;
- for (int j = 0; j < Block8x8F.ScalarCount; j++)
- {
- dqt[offset++] = (byte)q[j];
- }
- }
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsInvalidStretchArea(PixelArea area, int fromX, int fromY)
where TColor : struct, IPackedPixel, IEquatable