Terrarium.Renderer.DirectX.DirectDrawSpriteSurface.DirectDrawSpriteSurface C# (CSharp) Method

DirectDrawSpriteSurface() public method

Creates a new sprite sheet with the given name from an image. The sheet is broken into sprites given the number of horizontal and vertical frames available on this sheet.
public DirectDrawSpriteSurface ( string spriteName, string spriteImagePath, int xFrames, int yFrames ) : System
spriteName string The name of the sprite sheet
spriteImagePath string The path to the image to load.
xFrames int The number of horizontal frames on this sheet.
yFrames int The number of vertical frames on this sheet.
return System
        public DirectDrawSpriteSurface(string spriteName, string spriteImagePath, int xFrames, int yFrames)
        {
            #if TRACE
            GraphicsEngine.Profiler.Start("DirectDrawSpriteSurface..ctor()");
            #endif
            this.spriteName = spriteName;

            ddsurface = new DirectDrawSurface(spriteImagePath);
            if (ddsurface == null)
            {
                ddsurface = new DirectDrawSurface(spriteImagePath, DirectDrawSurface.SystemMemorySurfaceDescription);
            }
            ddsurface.TransparencyKey = new ColorKey(DirectDrawSurface.DefaultColorKey);

            animationFrames = xFrames;
            animationTypes = yFrames;

            frameHeight = ddsurface.Rect.Bottom/animationTypes;
            frameWidth = ddsurface.Rect.Right/animationFrames;
            #if TRACE
            GraphicsEngine.Profiler.End("DirectDrawSpriteSurface..ctor()");
            #endif
        }