DepthOfFieldEffectSerializer.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.IO;
  2. namespace MeidoPhotoStudio.Plugin;
  3. public class DepthOfFieldEffectSerializer : Serializer<DepthOfFieldEffectManager>
  4. {
  5. private const short Version = 1;
  6. public override void Serialize(DepthOfFieldEffectManager effect, BinaryWriter writer)
  7. {
  8. writer.Write(DepthOfFieldEffectManager.Header);
  9. writer.WriteVersion(Version);
  10. writer.Write(effect.Active);
  11. writer.Write(effect.FocalLength);
  12. writer.Write(effect.FocalSize);
  13. writer.Write(effect.Aperture);
  14. writer.Write(effect.MaxBlurSize);
  15. writer.Write(effect.VisualizeFocus);
  16. }
  17. public override void Deserialize(DepthOfFieldEffectManager effect, BinaryReader reader, SceneMetadata metadata)
  18. {
  19. _ = reader.ReadVersion();
  20. var active = reader.ReadBoolean();
  21. effect.FocalLength = reader.ReadSingle();
  22. effect.FocalSize = reader.ReadSingle();
  23. effect.Aperture = reader.ReadSingle();
  24. effect.MaxBlurSize = reader.ReadSingle();
  25. effect.VisualizeFocus = reader.ReadBoolean();
  26. effect.SetEffectActive(active);
  27. }
  28. }