public void Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref FilePath);
     serializer.Serialize(ref Index);
     serializer.Serialize(ref UVIndex);
     serializer.Serialize(ref BlendFactor);
     serializer.SerializeEnum(ref Operation);
     serializer.SerializeEnum(ref WrapMode);
     serializer.SerializeEnum(ref Flags);
 }
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref FilePath);
     serializer.Serialize(ref DependencyFilePath);
     serializer.SerializeEnum(ref CompilerFlags);
     serializer.Serialize(ref Macros, SerializeFlags.Nullable);
     serializer.Serialize(ref IncludeDirectoryList, serializer.Serialize, SerializeFlags.Nullable);
 }
            public void Serialize(BinarySerializer serializer)
            {
                int expectedBlockSize = 0;
                serializer.Serialize(ref expectedBlockSize);

                var blockPosition = serializer.Stream.Position;

                serializer.Serialize(ref LineHeight);
                serializer.Serialize(ref Base);
                serializer.Serialize(ref ScaleW);
                serializer.Serialize(ref ScaleH);
                serializer.Serialize(ref PageCount);
                serializer.Serialize(ref BitField);
                serializer.SerializeEnum(ref Alpha);
                serializer.SerializeEnum(ref Red);
                serializer.SerializeEnum(ref Green);
                serializer.SerializeEnum(ref Blue);

                var blockSize = serializer.Stream.Position - blockPosition;
                if (blockSize != expectedBlockSize)
                    throw new NotSupportedException("Invalid BMF font format");
            }
        /// <summary>
        ///  This method for loading/saving a font file generated from MakeSpriteFont.
        /// </summary>
        /// <param name="serializer">The binary serializer to use.</param>
        /// <returns></returns>
        private void SerializeMakeSpriteFont(BinarySerializer serializer)
        {
            FourCC magicCode2 = "font";
            serializer.Serialize(ref magicCode2);
            if (magicCode2 != "font")
                return;

            // Writes the version
            if (serializer.Mode == SerializerMode.Read)
            {
                int version = serializer.Reader.ReadInt32();
                if (version != Version)
                {
                    throw new NotSupportedException(string.Format("SpriteFontData version [0x{0:X}] is not supported. Expecting [0x{1:X}]", version, Version));
                }
            }
            else
            {
                serializer.Writer.Write(Version);
            }
            
            // Deserialize Glyphs
            int glyphCount = 0;
            serializer.Serialize(ref glyphCount);

            // For MakeSpriteFont, there is only one GlyphPage.
            Glyphs = new Glyph[glyphCount];
            for (int i = 0; i < glyphCount; i++)
            {
                serializer.Serialize(ref Glyphs[i].Character);
                serializer.Serialize(ref Glyphs[i].Subrect);
                serializer.Serialize(ref Glyphs[i].Offset);
                serializer.Serialize(ref Glyphs[i].XAdvance);
            }

            serializer.Serialize(ref LineSpacing);
            serializer.Serialize(ref DefaultCharacter);

            var image = new BitmapData();
            Bitmaps = new Bitmap[1] {new Bitmap()};
            Bitmaps[0].Data = image;

            serializer.Serialize(ref image.Width);
            serializer.Serialize(ref image.Height);
            serializer.SerializeEnum(ref image.PixelFormat);
            serializer.Serialize(ref image.RowStride);
            serializer.Serialize(ref image.CompressedHeight);
            serializer.Serialize(ref image.Data, image.RowStride * image.CompressedHeight);
        }
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Width);
     serializer.Serialize(ref Height);
     serializer.SerializeEnum(ref PixelFormat);
     serializer.Serialize(ref RowStride);
     serializer.Serialize(ref CompressedHeight);
     serializer.Serialize(ref Data, RowStride * CompressedHeight);
 }
Esempio n. 6
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Name, SerializeFlags.Nullable);
     serializer.SerializeEnum(ref Type);
     serializer.SerializeEnum(ref CompilerFlags);
     serializer.SerializeEnum(ref Level);
     serializer.Serialize(ref Bytecode);
     serializer.Serialize(ref Hashcode);
     serializer.Serialize(ref InputSignature);
     serializer.Serialize(ref OutputSignature);
     serializer.Serialize(ref ConstantBuffers);
     serializer.Serialize(ref ResourceParameters);
 }