private static Texture2D AnimationFromBitmap(RTSRenderer renderer, string fi) { Texture2D t; float[] sData = null; int w, h; using (var bmp = System.Drawing.Bitmap.FromFile(fi) as System.Drawing.Bitmap) { w = bmp.Width; h = bmp.Height; sData = new float[w * h]; System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, w, h), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat); System.Runtime.InteropServices.Marshal.Copy(data.Scan0, sData, 0, (data.Stride * data.Height) >> 2); bmp.UnlockBits(data); } t = renderer.CreateTexture2D(w, h, SurfaceFormat.Single); t.SetData(sData); return(t); }