/// <summary> /// Draws a Texture. /// </summary> /// <param name="texture">The Texture.</param> /// <param name="source">The SourceRectangle.</param> /// <param name="destination">The DestinationRectangle.</param> /// <param name="color">The Color.</param> /// <param name="opacity">The Opacity.</param> public void DrawTexture(Texture2D texture, Rectangle source, Rectangle destination, Color color, float opacity = 1) { var dxTexture = texture as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX10 expects a DirectXTexture as resource."); } Bitmap dxBmp = dxTexture.GetBitmap(); DirectXHelper.RenderTarget.DrawBitmap(dxBmp, DirectXHelper.ConvertRectangleF(destination), opacity, InterpolationMode == InterpolationMode.Linear ? SlimDX.Direct2D.InterpolationMode.Linear : SlimDX.Direct2D.InterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangleF(source)); }
/// <summary> /// Draws a Texture. /// </summary> /// <param name="spriteSheet">The SpriteSheet.</param> /// <param name="rectangle">The Rectangle.</param> /// <param name="color">The Color.</param> /// <param name="opacity">The Opacity.</param> public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1) { var dxTexture = spriteSheet.Texture2D as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX10 expects a DirectXTexture as resource."); } Bitmap dxBmp = dxTexture.GetBitmap(); DirectXHelper.RenderTarget.DrawBitmap(dxBmp, new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), opacity, InterpolationMode == InterpolationMode.Linear ? SlimDX.Direct2D.InterpolationMode.Linear : SlimDX.Direct2D.InterpolationMode.NearestNeighbor, DirectXHelper.ConvertRectangleF(spriteSheet.Rectangle)); }