Browse Source

Added optimized implementation for CopyFromXYZW and CopyFromXYZ.

pull/30/head
dirk 9 years ago
committed by Dirk Lemstra
parent
commit
7c6b73d2e2
  1. 25
      src/ImageSharp/PixelAccessor.cs

25
src/ImageSharp/PixelAccessor.cs

@ -5,7 +5,6 @@
namespace ImageSharp
{
using System;
using System.Runtime.CompilerServices;
/// <summary>
@ -22,6 +21,30 @@ namespace ImageSharp
{
}
/// <inheritdoc />
protected override void CopyFromXYZW(PixelRow<Color, uint> row, int targetY, int targetX, int width)
{
byte* source = row.PixelBase;
byte* destination = this.GetRowPointer(targetY) + targetX;
Unsafe.CopyBlock(destination, source, (uint) width * 4);
}
/// <inheritdoc />
protected override void CopyFromXYZ(PixelRow<Color, uint> row, int targetY, int targetX, int width)
{
byte* source = row.PixelBase;
byte* destination = this.GetRowPointer(targetY) + targetX;
for (int x = 0; x < width; x++)
{
Unsafe.Write(destination, (uint)(*(source) << 0 | *(source + 1) << 8 | *(source + 2) << 16 | 255 << 24));
source += 3;
destination += 4;
}
}
/// <inheritdoc />
protected override void CopyFromZYX(PixelRow<Color, uint> row, int targetY, int targetX, int width)
{

Loading…
Cancel
Save