NScumm.Core.Graphics.Surface.Surface C# (CSharp) Method

Surface() public method

Allocate memory for the pixel data of the surface.
public Surface ( int width, int height, PixelFormat format, bool trick ) : System
width int Width of the surface object.
height int Height of the surface objec.t
format PixelFormat The pixel format the surface should use.
trick bool
return System
        public Surface(int width, int height, PixelFormat format, bool trick)
        {
            if (width < 0)
                throw new ArgumentOutOfRangeException("width", "Width should be positive");
            if (height < 0)
                throw new ArgumentOutOfRangeException("height", "Height should be positive");

            Width = width;
            Height = height;
            PixelFormat = format;

            BytesPerPixel = GetBytesPerPixel(format);

            Pitch = width * BytesPerPixel;
            if (trick)
            {
                _buffer = new byte[Pitch * height + 8 * Pitch];
            }
            else
            {
                _buffer = new byte[Pitch * height];
            }
        }