/// <summary> /// Creates an <see cref="Texture"/> from an array of bytes. The color is assumed to be in R8G8B8A8 format. /// </summary> /// <param name="image">The image.</param> /// <param name="source">The <see cref="Rectangle"/> to copy on the source image.</param> /// <returns> /// The <see cref="Bitmap"/> containing the <paramref name="image"/>. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="image"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">The <paramref name="source"/> specifies an area /// outside of the <paramref name="image"/>.</exception> public static Bitmap ToBitmap(this Texture image, SFML.Graphics.Rectangle source) { if (image == null) throw new ArgumentNullException("image"); return ToBitmap(image, new Rectangle(source.X, source.Y, source.Width, source.Height)); }
/// <summary> /// Creates an <see cref="Texture"/> from an array of bytes. The color is assumed to be in R8G8B8A8 format. /// </summary> /// <param name="image">The image.</param> /// <param name="source">The <see cref="Rectangle"/> to copy on the source image.</param> /// <param name="destWidth">The width of the generated image.</param> /// <param name="destHeight">The height of the generated image.</param> /// <returns> /// The <see cref="Bitmap"/> containing the <paramref name="image"/>. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="image"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">The <paramref name="source"/> specifies an area /// outside of the <paramref name="image"/>.</exception> public static Bitmap ToBitmap(this Texture image, SFML.Graphics.Rectangle source, int destWidth, int destHeight) { if (image == null) { throw new ArgumentNullException("image"); } var rect = new Rectangle(source.X, source.Y, source.Width, source.Height); return(ToBitmap(image, rect, destWidth, destHeight)); }