diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
index a121a0bc2..d0bf8439a 100644
--- a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
@@ -2,6 +2,7 @@
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
+
namespace ImageSharp.Formats
{
using System;
@@ -230,18 +231,24 @@ namespace ImageSharp.Formats
/// Writes data to "Define Quantization Tables" block for QuantIndex
///
/// The "Define Quantization Tables" block
- /// Offset in dqt
+ /// Offset in "Define Quantization Tables" block
/// The quantization index
- /// The quantazation table to copy data from
- private static void WriteDataToDqt(byte[] dqt, ref int offset, QuantIndex i, ref Block8x8F q)
+ /// The quantization table to copy data from
+ private static void WriteDataToDqt(byte[] dqt, ref int offset, QuantIndex i, ref Block8x8F quant)
{
dqt[offset++] = (byte)i;
for (int j = 0; j < Block8x8F.ScalarCount; j++)
{
- dqt[offset++] = (byte)q[j];
+ dqt[offset++] = (byte)quant[j];
}
}
+ ///
+ /// Initializes quantization table.
+ ///
+ /// The quantization index.
+ /// The scaling factor.
+ /// The quantization table.
private static void InitQuantizationTable(int i, int scale, ref Block8x8F quant)
{
for (int j = 0; j < Block8x8F.ScalarCount; j++)
@@ -517,7 +524,7 @@ namespace ImageSharp.Formats
/// Temporal block to be used as FDCT Destination
/// Temporal block 2
/// Quantization table
- /// The 8x8 Unzig block ptr
+ /// The 8x8 Unzig block pointer
///
/// The
///
diff --git a/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs b/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
index 7608c70c6..e11a8a71c 100644
--- a/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
+++ b/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs
@@ -93,7 +93,7 @@ namespace ImageSharp.Formats.Jpg
for (int y = 0; y < fromY; y++)
{
- byte* ptrBase = (byte*)area.DataPointer + (y * area.RowByteCount);
+ byte* ptrBase = (byte*)area.DataPointer + (y * area.RowStride);
for (int x = fromX; x < area.Width; x++)
{
@@ -106,8 +106,8 @@ namespace ImageSharp.Formats.Jpg
for (int y = fromY; y < area.Height; y++)
{
- byte* currBase = (byte*)area.DataPointer + (y * area.RowByteCount);
- byte* prevBase = (byte*)area.DataPointer + ((y - 1) * area.RowByteCount);
+ byte* currBase = (byte*)area.DataPointer + (y * area.RowStride);
+ byte* prevBase = (byte*)area.DataPointer + ((y - 1) * area.RowStride);
for (int x = 0; x < area.Width; x++)
{
diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs
index 178ea5274..a265bdddb 100644
--- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs
+++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs
@@ -292,7 +292,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -321,7 +321,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -350,7 +350,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -379,7 +379,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -405,7 +405,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- int offset = y * area.RowByteCount;
+ int offset = y * area.RowStride;
for (int x = 0; x < width; x++)
{
this[sourceX + x, sourceY + y].ToBytes(area.Bytes, offset, ComponentOrder.ZYX);
@@ -426,7 +426,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- int offset = y * area.RowByteCount;
+ int offset = y * area.RowStride;
for (int x = 0; x < width; x++)
{
this[sourceX + x, sourceY + y].ToBytes(area.Bytes, offset, ComponentOrder.ZYXW);
@@ -447,7 +447,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- int offset = y * area.RowByteCount;
+ int offset = y * area.RowStride;
for (int x = 0; x < width; x++)
{
this[sourceX + x, sourceY + y].ToBytes(area.Bytes, offset, ComponentOrder.XYZ);
@@ -468,7 +468,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- int offset = y * area.RowByteCount;
+ int offset = y * area.RowStride;
for (int x = 0; x < width; x++)
{
this[sourceX + x, sourceY + y].ToBytes(area.Bytes, offset, ComponentOrder.XYZW);
diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TColor}.cs
index b1ae5f870..8e03e8b31 100644
--- a/src/ImageSharp/Image/PixelArea{TColor}.cs
+++ b/src/ImageSharp/Image/PixelArea{TColor}.cs
@@ -75,7 +75,7 @@ namespace ImageSharp
this.Width = width;
this.Height = height;
this.ComponentOrder = componentOrder;
- this.RowByteCount = width * GetComponentCount(componentOrder);
+ this.RowStride = width * GetComponentCount(componentOrder);
this.Bytes = bytes;
this.pixelsHandle = GCHandle.Alloc(this.Bytes, GCHandleType.Pinned);
@@ -132,9 +132,9 @@ namespace ImageSharp
this.Width = width;
this.Height = height;
this.ComponentOrder = componentOrder;
- this.RowByteCount = (width * GetComponentCount(componentOrder)) + padding;
+ this.RowStride = (width * GetComponentCount(componentOrder)) + padding;
- int bufferSize = this.RowByteCount * height;
+ int bufferSize = this.RowStride * height;
if (usePool)
{
@@ -188,9 +188,9 @@ namespace ImageSharp
public byte* PixelBase { get; private set; }
///
- /// Gets number of bytes in a row.
+ /// Gets the width of one row in the number of bytes.
///
- public int RowByteCount { get; }
+ public int RowStride { get; }
///
/// Gets the width.
@@ -201,6 +201,7 @@ namespace ImageSharp
/// Gets the pool used to rent , when it's not coming from an external source
///
// ReSharper disable once StaticMemberInGenericType
+ // TODO: Use own pool?
private static ArrayPool BytesPool => ArrayPool.Shared;
///
@@ -234,7 +235,7 @@ namespace ImageSharp
///
internal void Reset()
{
- Unsafe.InitBlock(this.PixelBase, 0, (uint)(this.RowByteCount * this.Height));
+ Unsafe.InitBlock(this.PixelBase, 0, (uint)(this.RowStride * this.Height));
}
///
@@ -262,6 +263,16 @@ namespace ImageSharp
throw new NotSupportedException();
}
+ ///
+ /// Checks that the length of the byte array to ensure that it matches the given width and height.
+ ///
+ /// The width.
+ /// The height.
+ /// The byte array.
+ /// The component order.
+ ///
+ /// Thrown if the byte array is th incorrect length.
+ ///
[Conditional("DEBUG")]
private void CheckBytesLength(int width, int height, byte[] bytes, ComponentOrder componentOrder)
{
@@ -274,6 +285,10 @@ namespace ImageSharp
}
}
+ ///
+ /// Disposes the object and frees resources for the Garbage Collector.
+ ///
+ /// If true, the object gets disposed.
private void Dispose(bool disposing)
{
if (this.isDisposed)
diff --git a/src/ImageSharp/PixelAccessor.cs b/src/ImageSharp/PixelAccessor.cs
index c91f10cbd..869837034 100644
--- a/src/ImageSharp/PixelAccessor.cs
+++ b/src/ImageSharp/PixelAccessor.cs
@@ -28,7 +28,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
Unsafe.CopyBlock(destination, source, byteCount);
@@ -40,7 +40,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -58,7 +58,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -76,7 +76,7 @@ namespace ImageSharp
{
for (int y = 0; y < height; y++)
{
- byte* source = area.PixelBase + (y * area.RowByteCount);
+ byte* source = area.PixelBase + (y * area.RowStride);
byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++)
@@ -95,7 +95,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
byte* source = this.GetRowPointer(sourceX, sourceY + y);
- byte* destination = area.PixelBase + (y * area.RowByteCount);
+ byte* destination = area.PixelBase + (y * area.RowStride);
for (int x = 0; x < width; x++)
{
@@ -115,7 +115,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
byte* source = this.GetRowPointer(sourceX, sourceY + y);
- byte* destination = area.PixelBase + (y * area.RowByteCount);
+ byte* destination = area.PixelBase + (y * area.RowStride);
for (int x = 0; x < width; x++)
{
@@ -135,7 +135,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++)
{
byte* source = this.GetRowPointer(sourceX, sourceY + y);
- byte* destination = area.PixelBase + (y * area.RowByteCount);
+ byte* destination = area.PixelBase + (y * area.RowStride);
for (int x = 0; x < width; x++)
{