//[Fact] public void Unscaled() { Block8x8F block = CreateRandomFloatBlock(0, 100); using (var buffer = new Buffer2D <float>(20, 20)) { BufferArea <float> area = buffer.GetArea(5, 10, 8, 8); block.CopyTo(area); Assert.Equal(block[0, 0], buffer[5, 10]); Assert.Equal(block[1, 0], buffer[6, 10]); Assert.Equal(block[0, 1], buffer[5, 11]); Assert.Equal(block[0, 7], buffer[5, 17]); Assert.Equal(block[63], buffer[12, 17]); VerifyAllZeroOutsideSubArea(buffer, 5, 10); } }
public void Copy1x1Scale() { Block8x8F block = CreateRandomFloatBlock(0, 100); using (Buffer2D <float> buffer = Configuration.Default.MemoryAllocator.Allocate2D <float>(20, 20, AllocationOptions.Clean)) { BufferArea <float> area = buffer.GetArea(5, 10, 8, 8); block.Copy1x1Scale(area); Assert.Equal(block[0, 0], buffer[5, 10]); Assert.Equal(block[1, 0], buffer[6, 10]); Assert.Equal(block[0, 1], buffer[5, 11]); Assert.Equal(block[0, 7], buffer[5, 17]); Assert.Equal(block[63], buffer[12, 17]); VerifyAllZeroOutsideSubArea(buffer, 5, 10); } }
public void GetRowSpan(int rx, int ry, int y, int w, int h) { using (Buffer2D <int> buffer = CreateTestBuffer(20, 30)) { Rectangle r = new Rectangle(rx, ry, w, h); BufferArea <int> area = buffer.GetArea(r); Span <int> span = area.GetRowSpan(y); Assert.Equal(w, span.Length); for (int i = 0; i < w; i++) { int expected = (ry + y) * 100 + rx + i; int value = span[i]; Assert.Equal(expected, value); } } }
public void GetRowSpan(int bufferCapacity, int rx, int ry, int y, int w, int h) { this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D <int> buffer = this.CreateTestBuffer(20, 30); var r = new Rectangle(rx, ry, w, h); BufferArea <int> area = buffer.GetArea(r); Span <int> span = area.GetRowSpan(y); Assert.Equal(w, span.Length); for (int i = 0; i < w; i++) { int expected = ((ry + y) * 100) + rx + i; int value = span[i]; Assert.Equal(expected, value); } }