public Add ( Stream inStream, byte data, uint &compressedSize ) : int | ||
inStream | Stream | The stream open on the resource cache. |
data | byte | The data to compress. |
compressedSize | uint | On return, the size of the compressed data. |
리턴 | int |
private bool ImportAnimationResource(TagInstance tagIndex, string cachePath, string dataPath) { ModelAnimationGraph animation; ResourceCache resourceCache; uint compressedSize = 0; var data = File.ReadAllBytes(dataPath); using (var cacheStream = _info.OpenCacheReadWrite()) { var tagContext = new TagSerializationContext(cacheStream, _info.Cache, _info.StringIDs, tagIndex); animation = _info.Deserializer.Deserialize<ModelAnimationGraph>(tagContext); } using (var stream = File.Open(_info.CacheFile.DirectoryName + "\\" + cachePath, FileMode.Open, FileAccess.ReadWrite)) { resourceCache = new ResourceCache(stream); animation.ResourceGroups[0].Resource.Index = resourceCache.Add(stream, data, out compressedSize); animation.ResourceGroups[0].Resource.CompressedSize = compressedSize; animation.ResourceGroups[0].Resource.OldLocationFlags = (OldResourceLocationFlags)2; } using (var cacheStream = _fileInfo.Open(FileMode.Open, FileAccess.ReadWrite)) { var context = new TagSerializationContext(cacheStream, _cache, _stringIds, tagIndex); _info.Serializer.Serialize(context, animation); } Console.WriteLine("{1}: Imported 0x{0}.", compressedSize, tagIndex); return true; }
private bool ImportBitmapResource(TagInstance tagIndex, string cachePath, string dataPath) { Bitmap bitmap; ResourceCache resourceCache; uint compressedSize = 0; using (var cacheStream = _info.OpenCacheRead()) { var tagContext = new TagSerializationContext(cacheStream, _info.Cache, _info.StringIDs, tagIndex); bitmap = _info.Deserializer.Deserialize<Bitmap>(tagContext); } using (var stream = File.Open(_info.CacheFile.DirectoryName + "\\" + cachePath, FileMode.Open, FileAccess.ReadWrite)) { int imageIndex = 0; foreach (string file in Directory.EnumerateFiles(dataPath, "*.bitm")) { byte[] inBitmapData = File.ReadAllBytes(file); resourceCache = new ResourceCache(stream); bitmap.Resources[imageIndex].Resource.Index = resourceCache.Add(stream, inBitmapData, out compressedSize); bitmap.Resources[imageIndex].Resource.CompressedSize = compressedSize; imageIndex++; } } using (var cacheStream = _fileInfo.Open(FileMode.Open, FileAccess.ReadWrite)) { var context = new TagSerializationContext(cacheStream, _cache, _stringIds, tagIndex); _info.Serializer.Serialize(context, bitmap); } Console.WriteLine("{1}: Imported 0x{0}.", compressedSize, tagIndex); return true; }
private bool ImportModelResource(TagInstance tagIndex, string cachePath, string dataPath) { RenderModel renderModel; ResourceCache resourceCache; uint compressedSize = 0; var data = File.ReadAllBytes(dataPath); using (var cacheStream = _info.OpenCacheReadWrite()) { var tagContext = new TagSerializationContext(cacheStream, _info.Cache, _info.StringIDs, tagIndex); renderModel = _info.Deserializer.Deserialize<RenderModel>(tagContext); } using (var stream = File.Open(_info.CacheFile.DirectoryName + "\\" + cachePath, FileMode.Open, FileAccess.ReadWrite)) { resourceCache = new ResourceCache(stream); renderModel.Geometry.Resource.Index = resourceCache.Add(stream, data, out compressedSize); renderModel.Geometry.Resource.CompressedSize = compressedSize; } using (var cacheStream = _fileInfo.Open(FileMode.Open, FileAccess.ReadWrite)) { var context = new TagSerializationContext(cacheStream, _cache, _stringIds, tagIndex); _info.Serializer.Serialize(context, renderModel); } Console.WriteLine("{1}: Imported 0x{0}.", compressedSize, tagIndex); return true; }