Показать сообщение отдельно
Старый 23.02.2013, 15:42   #243
wppt
Нуждающийся
 
Регистрация: 25.11.2012
Сообщений: 83
Написано 2 полезных сообщений
(для 2 пользователей)
Ответ: Вопросы по XNA.

кстати нашел еще код - результат его выполнения тот же:
        public static void imagetotexture(GraphicsDevice device, ref Texture2D texture, System.Drawing.Image image)
        {
            if (image == null)
                return;

            if (texture == null || texture.IsDisposed || texture.Width != image.Width || texture.Height !=
                image.Height || texture.Format != SurfaceFormat.Color)
            {
                if (texture != null && !texture.IsDisposed)
                    texture.Dispose();
                texture = new Texture2D(device, image.Width, image.Height, false, SurfaceFormat.Color);
            }
            else
            {
                for (int i = 0; i < 16; i++)
                    if (device.Textures[i] == texture)
                    {
                        device.Textures[i] = null;
                        break;
                    }
            }

            using (MemoryStream mstream = new MemoryStream())
            {
                image.Save(mstream, System.Drawing.Imaging.ImageFormat.Png);
                mstream.Seek(0, SeekOrigin.Begin);
                texture = Texture2D.FromStream(device, mstream, image.Width, image.Height, false);
            }
        }
(Offline)
 
Ответить с цитированием