Ejemplo n.º 1
0
        private void ConvertTexture2D(Texture2D m_Texture2D, string name)
        {
            var iTex = ImportedHelpers.FindTexture(name, TextureList);

            if (iTex != null)
            {
                return;
            }

            var stream = m_Texture2D.ConvertToStream(imageFormat, true);

            if (stream != null)
            {
                using (stream)
                {
                    iTex = new ImportedTexture(stream, name);
                    TextureList.Add(iTex);
                }
            }
        }
Ejemplo n.º 2
0
        private void ConvertTexture2D(Texture2D tex2D, string name)
        {
            var iTex = ImportedHelpers.FindTexture(name, TextureList);

            if (iTex != null)
            {
                return;
            }

            using (var memStream = new MemoryStream())
            {
                var bitmap = new Texture2DConverter(tex2D).ConvertToBitmap(true);
                if (bitmap != null)
                {
                    bitmap.Save(memStream, ImageFormat.Png);
                    memStream.Position = 0;
                    iTex = new ImportedTexture(memStream, name);
                    TextureList.Add(iTex);
                }
            }
        }
Ejemplo n.º 3
0
        private void ConvertTexture2D(Texture2D m_Texture2D, string name)
        {
            var iTex = ImportedHelpers.FindTexture(name, TextureList);

            if (iTex != null)
            {
                return;
            }

            var bitmap = m_Texture2D.ConvertToBitmap(true);

            if (bitmap != null)
            {
                using (var stream = new MemoryStream())
                {
                    switch (imageFormat)
                    {
                    case "BMP":
                        bitmap.Save(stream, ImageFormat.Bmp);
                        break;

                    case "PNG":
                        bitmap.Save(stream, ImageFormat.Png);
                        break;

                    case "JPEG":
                        bitmap.Save(stream, ImageFormat.Jpeg);
                        break;

                    case "TGA":
                        var tga = new TGA(bitmap);
                        tga.Save(stream);
                        break;
                    }
                    iTex = new ImportedTexture(stream, name);
                    TextureList.Add(iTex);
                    bitmap.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        private void ConvertTexture2D(Texture2D m_Texture2D, string name)
        {
            var iTex = ImportedHelpers.FindTexture(name, TextureList);

            if (iTex != null)
            {
                return;
            }

            var bitmap = m_Texture2D.ConvertToBitmap(true);

            if (bitmap != null)
            {
                using (var stream = new MemoryStream())
                {
                    bitmap.Save(stream, ImageFormat.Png);
                    iTex = new ImportedTexture(stream, name);
                    TextureList.Add(iTex);
                    bitmap.Dispose();
                }
            }
        }