Browse Source

Fixed issue with incorrect X offset in the PixelAccessor that was reported by Anton Firsov.

af/merge-core
Dirk Lemstra 10 years ago
parent
commit
b3ecf0ec73
  1. 15
      src/ImageSharp/Image/PixelAccessor.cs
  2. 12
      src/ImageSharp/PixelAccessor.cs

15
src/ImageSharp/Image/PixelAccessor.cs

@ -297,7 +297,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -326,7 +326,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -355,7 +355,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -384,7 +384,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -484,13 +484,14 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Gets the pointer at the specified row. /// Gets the pointer at the specified row.
/// </summary> /// </summary>
/// <param name="targetY">The target row index.</param> /// <param name="x">The column index.</param>
/// <param name="y">The row index.</param>
/// <returns> /// <returns>
/// The <see cref="T:byte*"/>. /// The <see cref="T:byte*"/>.
/// </returns> /// </returns>
protected byte* GetRowPointer(int targetY) protected byte* GetRowPointer(int x, int y)
{ {
return this.pixelsBase + ((targetY * this.Width) * Unsafe.SizeOf<TColor>()); return this.pixelsBase + (((y * this.Width) + x) * Unsafe.SizeOf<TColor>());
} }
[Conditional("DEBUG")] [Conditional("DEBUG")]

12
src/ImageSharp/PixelAccessor.cs

@ -29,7 +29,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
Unsafe.CopyBlock(destination, source, byteCount); Unsafe.CopyBlock(destination, source, byteCount);
} }
@ -41,7 +41,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -59,7 +59,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -77,7 +77,7 @@ namespace ImageSharp
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = area.PixelBase + (y * area.RowByteCount); byte* source = area.PixelBase + (y * area.RowByteCount);
byte* destination = this.GetRowPointer(targetY + y) + targetX; byte* destination = this.GetRowPointer(targetX, targetY + y);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
@ -94,7 +94,7 @@ namespace ImageSharp
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = this.GetRowPointer(sourceY + y) + sourceX; byte* source = this.GetRowPointer(sourceX, sourceY + y);
byte* destination = area.PixelBase + (y * area.RowByteCount); byte* destination = area.PixelBase + (y * area.RowByteCount);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
@ -114,7 +114,7 @@ namespace ImageSharp
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
byte* source = this.GetRowPointer(sourceY + y) + sourceX; byte* source = this.GetRowPointer(sourceX, sourceY + y);
byte* destination = area.PixelBase + (y * area.RowByteCount); byte* destination = area.PixelBase + (y * area.RowByteCount);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)

Loading…
Cancel
Save