示例#1
0
        public static Tim FromStream(Stream str)
        {
            frames.Clear();
            buffer = new Tim(new Rectangle(0, 0, Width, Height));

            using (BinaryReaderEx br = new BinaryReaderEx(str))
            {
                if (br.ReadInt32() == 0x20)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        br.ReadInt32();
                        Tim tim = new Tim(br);
                        //tim.Write("vram" + i.ToString("X2") + ".tim");
                        buffer.DrawTim(tim);

                        frames.Add(tim.region);

                        Console.WriteLine(tim.ToString());
                    }
                }
                else
                {
                    br.BaseStream.Position = 0;
                    Tim tim = new Tim(br);
                    //tim.Write("vram01.tim");
                    buffer.DrawTim(tim);

                    frames.Add(tim.region);

                    Console.WriteLine(tim.ToString());
                }

                //use this to dump whole vram as a single grayscale image
                //buffer.SaveBMP("vram.png", BMPHeader.GrayScalePalette(16));
                //buffer.Write("vram.tim");

                return(buffer);
            }
        }
示例#2
0
        public static Tim FromFile(string fn)
        {
            Tim buffer = new Tim(new Rectangle(0, 0, Width, Height));

            if (File.Exists(fn))
            {
                using (BinaryReaderEx br = new BinaryReaderEx(File.OpenRead(fn)))
                {
                    if (br.ReadInt32() == 0x20)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            br.ReadInt32();
                            Tim tim = new Tim(br);
                            //tim.Write("vram" + i.ToString("X2") + ".tim");
                            buffer.DrawTim(tim);

                            frames.Add(tim.region);

                            Console.WriteLine(tim.ToString());
                        }
                    }
                    else
                    {
                        br.BaseStream.Position = 0;
                        Tim tim = new Tim(br);
                        //tim.Write("vram01.tim");
                        buffer.DrawTim(tim);

                        frames.Add(tim.region);

                        Console.WriteLine(tim.ToString());
                    }
                }
            }
            return(buffer);
        }