/// <summary> /// Writes the WzImage object to the underlying WzBinaryWriter /// </summary> /// <param name="writer"></param> /// <param name="forceReadFromData">Read from data regardless of base data that's changed or not.</param> public void SaveImage(WzBinaryWriter writer, bool forceReadFromData = false) { if (changed || forceReadFromData) { if (reader != null && !parsed) { this.ParseEverything = true; ParseImage(forceReadFromData); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddPropertiesForWzImageDumping(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); } else { long pos = reader.BaseStream.Position; reader.BaseStream.Position = offset; writer.Write(reader.ReadBytes(size)); reader.BaseStream.Position = pos; } }
/// <summary> /// Writes the WzImage object to the underlying WzBinaryWriter /// </summary> /// <param name="writer"></param> /// <param name="bIsWzUserKeyDefault">Uses the default MapleStory UserKey or a custom key.</param> /// <param name="forceReadFromData">Read from data regardless of base data that's changed or not.</param> public void SaveImage(WzBinaryWriter writer, bool bIsWzUserKeyDefault = true, bool forceReadFromData = false) { if (bIsImageChanged || !bIsWzUserKeyDefault || // everything needs to be re-written when a custom UserKey is used forceReadFromData) // if its not being force-read and written, it saves with the previous WZ encryption IV. { if (reader != null && !parsed) { this.ParseEverything = true; ParseImage(forceReadFromData); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddPropertiesForWzImageDumping(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); } else { long pos = reader.BaseStream.Position; reader.BaseStream.Position = offset; writer.Write(reader.ReadBytes(size)); reader.BaseStream.Position = pos; } }
internal void SaveImage(WzBinaryWriter writer) { if (reader != null && !parsed) { ParseImage(); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); }
internal void SaveImage(WzBinaryWriter writer) { if (changed) { if (reader != null && !parsed) { ParseImage(); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); } else { long pos = reader.BaseStream.Position; reader.BaseStream.Position = offset; writer.Write(reader.ReadBytes(size)); reader.BaseStream.Position = pos; } }
internal void SaveImage(WzBinaryWriter writer) { if (Changed) { if (reader != null && !Parsed) { ParseImage(); } var imgProp = new WzSubProperty(); var startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); BlockSize = (int)(writer.BaseStream.Position - startPos); } else { var pos = reader.BaseStream.Position; reader.BaseStream.Position = Offset; writer.Write(reader.ReadBytes(BlockSize)); reader.BaseStream.Position = pos; } }