Esempio n. 1
0
        public void Fill(uint color)
        {
            SetLayer();

            TpsGraphWrapper.ClearScreen(color);
            //TpsGraphWrapper.MemSet(RawDataPtr, 0, _sizeInBytes);
        }
Esempio n. 2
0
        public unsafe void SetRawData(uint[] rawData)
        {
            if (rawData.Length != _width * _height)
                throw new ArgumentException("rawData size mismatch; should be width*height");

            fixed(uint *srcPtr = &rawData[0])
            TpsGraphWrapper.CopyMemoryCrt(_dataPtr + SizeofSpriteHeader, (uint)srcPtr, _sizeInBytes);
        }
Esempio n. 3
0
        private const uint TransparentColor = 0xFF000000; // need to use bgra format with alpha set to 255

        #endregion

        #region public constructors

        public Sprite(uint width, uint height)
        {
            _width             = width;
            _height            = height;
            _sizeInBytes       = _width * _height * 4;
            _sizeInBytesForMmx = (_sizeInBytes / 8) * 8;

            _dataPtr = TpsGraphWrapper.CreateSprite(width, height, 4);
        }
Esempio n. 4
0
        public void SetPixel(uint x, uint y, uint color)
        {
            if (x >= Width || y >= Height)
            {
                return;
            }

            SetLayer();

            TpsGraphWrapper.SetPixel(x, y, color);
        }
Esempio n. 5
0
        public void CopyPixelsTo(uint targetPtr)
        {
            //TpsGraphWrapper.MemCopyMmx(_dataPtr + SizeofSpriteHeader, targetPtr, _sizeInBytesForMmx);
            //TpsGraphWrapper.MemCopy(_dataPtr + SizeofSpriteHeader, targetPtr, _sizeInBytesForMmx);
            TpsGraphWrapper.CopyMemoryCrt(targetPtr, _dataPtr + SizeofSpriteHeader, _sizeInBytes);

            // http://stackoverflow.com/questions/14834108/speed-copy-bitmap-data-into-array-or-work-with-it-directly
            // http://stackoverflow.com/questions/13511661/create-bitmap-from-double-two-dimentional-array
            // http://stackoverflow.com/questions/8104461/pixelformat-format32bppargb-seems-to-have-wrong-byte-order
            // http://code.google.com/p/renderterrain/source/browse/trunk/Utilities/FastBitmap.cs?r=18
            // Yeah! http://msdn.microsoft.com/en-us/library/system.windows.interop.imaging.createbitmapsourcefrommemorysection.aspx
        }
Esempio n. 6
0
        public void PutSprite(uint x, uint y, Sprite sprite, BlendMode?blendMode)
        {
            SetLayer();

            if (blendMode == null)
            {
                TpsGraphWrapper.PutSprite(x, y, TransparentColor, sprite._dataPtr);
            }
            else
            {
                TpsGraphWrapper.PutSpriteBlend(x, y, sprite._dataPtr, (byte)blendMode);
            }
        }
Esempio n. 7
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
            }

            // free native resources if there are any.
            if (!_disposed)
            {
                _disposed = true;
                if (_shouldFreeSprite)
                {
                    TpsGraphWrapper.ReleaseSprite(_dataPtr);
                }
            }
        }
Esempio n. 8
0
        public uint GetPixel(uint x, uint y)
        {
            SetLayer();

            return(TpsGraphWrapper.GetPixel(x, y));
        }
Esempio n. 9
0
 private void SetLayer()
 {
     TpsGraphWrapper.SetCurrentLayer(_dataPtr);
 }
Esempio n. 10
0
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return($"{Width}x{Height}, {_sizeInBytes + TpsGraphWrapper.GetSpriteHeaderSize()} bytes");
 }