Exemple #1
0
        public void Save(TextureFormat texture, Stream outFormatData)
        {
            TIM2Texture tim2 = texture as TIM2Texture;

            if (tim2 == null)
            {
                throw new TextureFormatException("Not a valid TIM2Texture!");
            }

            BinaryWriter writer = new BinaryWriter(outFormatData);

            writer.Write("TIM2".ToCharArray());
            writer.Write((ushort)tim2.Version);
            writer.Write((ushort)tim2.TIM2SegmentsList.Count);

            for (int i = 0; i < 8; i++)
            {
                writer.Write((byte)0);
            }

            TIM2SegmentSerializer serializer = new TIM2SegmentSerializer(tim2.Swizzled);

            foreach (TIM2Segment segment in tim2.TIM2SegmentsList)
            {
                serializer.Save(segment, outFormatData);
            }
        }
Exemple #2
0
        public void Export(TextureFormat texture, MetadataWriter metadata, string directory, string basename)
        {
            TIM2Texture tim2 = texture as TIM2Texture;

            if (tim2 == null)
            {
                throw new TextureFormatException("Not a valid TIM2Texture!");
            }

            metadata.BeginSection("TIM2");
            metadata.PutAttribute("Version", tim2.Version);
            metadata.PutAttribute("Basename", basename);
            metadata.PutAttribute("Swizzled", tim2.Swizzled);

            metadata.PutAttribute("Textures", tim2.TIM2SegmentsList.Count);
            int layer = 0;

            foreach (TIM2Segment segment in tim2.TIM2SegmentsList)
            {
                TextureFormatSerializer serializer = new TIM2SegmentSerializer();
                serializer.Export(segment, metadata, directory, basename + "_layer" + layer++);
            }

            metadata.EndSection();
        }
Exemple #3
0
        public TextureFormat Open(Stream formatData)
        {
            int version, textureCount;

            ReadHeader(formatData, out version, out textureCount);

            //construct images
            List <TIM2Segment> imagesList = new List <TIM2Segment>();

            for (int i = 0; i < textureCount; i++)
            {
                TextureFormatSerializer serializer = new TIM2SegmentSerializer();
                TIM2Segment             segment    = (TIM2Segment)serializer.Open(formatData);
                imagesList.Add(segment);
            }

            TIM2Texture tim = new TIM2Texture(imagesList);

            tim.Version = version;
            return(tim);
        }