public void CopyFromInvalidArgs() { var result = new PixelBuffer(PixelFormat.ABGR8888, new Size(40, 50)); AssertX.Throws <ArgumentNullException>(() => result.CopyFrom(null, new Rectangle(), Point.Zero, true)); AssertX.Throws <ArgumentOutOfRangeException>(() => result.CopyFrom(src, new Rectangle(-4, -4, 4, 4), Point.Zero, true)); AssertX.Throws <ArgumentOutOfRangeException>(() => result.CopyFrom(src, new Rectangle(0, 0, 4, 4), new Point(-4, -4), true)); AssertX.Throws <ArgumentException>(() => result.CopyFrom(src, new Rectangle(0, 0, 30, 20), new Point(39, 49), false)); AssertX.Throws <ArgumentException>(() => result.CopyFrom(src, new Rectangle(0, 0, 30, 20), new Point(0, 49), false)); }
public void CopyFromDifferentFormat() { var result = new PixelBuffer(PixelFormat.ARGB8888, new Size(30, 20)); result.CopyFrom(src, new Rectangle(Point.Zero, src.Size), Point.Zero, false); VerifyCopyResult(result); }
public void CopyPixels() { var result = new PixelBuffer(PixelFormat.ABGR8888, new Size(40, 50)); var destPt = new Point(5, 5); result.CopyFrom(src, new Rectangle(0, 0, 30, 20), destPt, true); VerifyCopyResult(result, src, destPt); }
/// <summary> /// Writes pixel data to the surface. /// </summary> /// <param name="buffer"></param> /// <param name="startPoint"></param> public virtual void WritePixels(PixelBuffer buffer, Point startPoint) { // poor man's method PixelBuffer pixels = ReadPixels(PixelFormat.RGBA8888); pixels.CopyFrom(buffer, new Rectangle(Point.Empty, buffer.Size), startPoint, false); WritePixels(pixels); }
public void CopyFromSkipTransparent() { var result = new PixelBuffer(PixelFormat.ARGB8888, new Size(30, 20)); src.SetPixel(0, 0, Color.FromArgb(0, 255, 255, 255)); result.CopyFrom(src, new Rectangle(Point.Zero, src.Size), Point.Zero, false, true); VerifyCopyResult(result); }
public void PixelsEqualSameFormat() { var result = new PixelBuffer(PixelFormat.ABGR8888, src.Size); result.CopyFrom(src, new Rectangle(Point.Zero, src.Size), Point.Zero, false); VerifyCopyResult(result); Assert.IsTrue(PixelBuffer.PixelsEqual(result, src)); result.SetPixel(0, 0, Color.Black); Assert.IsFalse(PixelBuffer.PixelsEqual(src, result)); }
/// <summary> /// Builds a surface of the specified size, using the information /// generated by the SurfacePacker. /// </summary> /// <param name="size"></param> /// <param name="packedRects"></param> /// <returns></returns> public virtual Surface BuildPackedSurface(Size size, SurfacePacker.RectPacker <Surface> packedRects) { PixelBuffer buffer = new PixelBuffer(Display.DefaultSurfaceFormat, size); foreach (SurfacePacker.RectHolder <Surface> rect in packedRects) { Surface surf = rect.Tag; Rectangle dest = rect.Rect; PixelBuffer pixels = surf.ReadPixels(); buffer.CopyFrom(pixels, new Rectangle(Point.Empty, surf.SurfaceSize), dest.Location, false); } Surface retval = new Surface(buffer); foreach (SurfacePacker.RectHolder <Surface> rect in packedRects) { rect.Tag.SetSourceSurface(retval, rect.Rect); } return(retval); }