Exemplo n.º 1
0
        private void btnTexSave_Click(object sender, EventArgs e)
        {
            TSOTex tex = GetSelectedTexture();

            if (tex == null)
            {
                return;
            }

            saveFileDialog1.FileName = tex.FileName.Trim('"');
            saveFileDialog1.Filter   = "Texture files (*.tga;*.bmp)|*.tga;*.bmp|All files (*.*)|*.*";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string ext = Path.GetExtension(saveFileDialog1.FileName).ToLower();
                using (BinaryWriter bw = new BinaryWriter(saveFileDialog1.OpenFile()))
                {
                    if (ext == ".tga")
                    {
                        tex.SaveTGA(bw);
                    }
                    else
                    if (ext == ".bmp")
                    {
                        tex.SaveBMP(bw);
                    }
                }
            }
        }
Exemplo n.º 2
0
        static Image GetImage(TSOTex tex)
        {
            if (tex.data.Length == 0)
            {
                return(null);
            }
            Image        image;
            MemoryStream ms = new MemoryStream();

            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                tex.SaveBMP(bw);
                bw.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                image = Bitmap.FromStream(ms);
            }
            return(image);
        }