public DirectDrawClippedRect GrabSprite(int xFrame, int yFrame, Rectangle dest, Rectangle bounds, int factor)
{
#if TRACE
GraphicsEngine.Profiler.Start("DirectDrawSpriteSurface.GrabSprite(int, int, RECT, RECT, int)");
#endif
if (xFrame < 0 || xFrame >= animationFrames ||
yFrame < 0 || yFrame >= animationTypes)
{
throw new Exception("Sprite request is out of range");
}
var spriteRect = new Rectangle(xFrame, yFrame, frameWidth, frameHeight);
var ddClipRect = new DirectDrawClippedRect();
ddClipRect.Destination = dest;
ddClipRect.Source = spriteRect;
if (dest.Left >= bounds.Right || dest.Right <= bounds.Left || dest.Top >= bounds.Bottom ||
dest.Bottom <= bounds.Top)
{
ddClipRect.Invisible = true;
#if TRACE
GraphicsEngine.Profiler.End("DirectDrawSpriteSurface.GrabSprite(int, int, RECT, RECT, int)");
#endif
return ddClipRect;
}
ddClipRect.ClipRectBounds(dest, bounds, factor);
#if TRACE
GraphicsEngine.Profiler.End("DirectDrawSpriteSurface.GrabSprite(int, int, RECT, RECT, int)");
#endif
return ddClipRect;
}