Exemple #1
0
        public static GameImage FromTex(TexFileReader reader)
        {
            const short x = 0;
            const short y = 0;

            using (DisposableStack insurance = new DisposableStack(2))
            {
                GLTexture layer    = insurance.Add(reader.ReadImage());
                GLTexture palettes = insurance.Add(GLTextureFactory.FromBitmapPalettes(reader.Palettes));
                GameImage result   = new GameImage(x, y, layer, palettes);
                insurance.Clear();
                return(result);
            }
        }
Exemple #2
0
        public static GameImage FromTim(TimFileReader reader)
        {
            using (DisposableStack insurance = new DisposableStack(3))
            {
                TimImage timImage = insurance.Add(reader.ReadImage());
                short    x        = timImage.ImageHeader.X;
                short    y        = timImage.ImageHeader.Y;

                GLTexture layer    = timImage.Layer;
                GLTexture palettes = insurance.Add(GLTextureFactory.FromBitmapPalettes(reader.Palettes == null ? null : reader.Palettes.Palettes));

                GameImage result = new GameImage(x, y, layer, palettes);
                insurance.Clear();
                return(result);
            }
        }
        private static DxTexture[] ReadTextures(ImgbArchiveAccessor accessor, TextureSection[] gtexDatas)
        {
            DxTexture[] textures = new DxTexture[gtexDatas.Length];

            using (Stream imgbStream = accessor.ExtractContent())
                using (DisposableStack insurance = new DisposableStack())
                {
                    for (int i = 0; i < gtexDatas.Length; i++)
                    {
                        GtexData data = gtexDatas[i].Gtex;
                        textures[i] = insurance.Add(ReadTexture(imgbStream, data));
                    }
                    insurance.Clear();
                }

            return(textures);
        }
Exemple #4
0
        public static void CreatePipe(long capacity, out Stream input, out Stream output)
        {
            using (DisposableStack insurance = new DisposableStack(3))
            {
                Flute flute = insurance.Add(new Flute(capacity));
                Stream writer = insurance.Add(flute.AcquireWriter(0, capacity));
                Stream reader = insurance.Add(flute.AcquireReader(0, capacity));

                DisposableStream disposableOutput = new DisposableStream(reader);
                disposableOutput.AfterDispose.Add(flute);
                disposableOutput.AfterDispose.Add(writer);

                input = writer;
                output = disposableOutput;

                insurance.Clear();
            }
        }