public void CheckMImage(int index) { if (!_initialized) { Initialize(); } if (index < 0 || index >= Images.Length) { return; } if (_indexList[index] == 0) { Images[index] = new WTLImage(); return; } WTLImage image = Images[index]; if (image == null) { _fStream.Seek(_indexList[index], SeekOrigin.Begin); image = new WTLImage(_bReader); Images[index] = image; image.CreateTexture(_bReader); } }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Lib"); if (File.Exists(fileName)) { File.Delete(fileName); } MLibrary library = new MLibrary(fileName) { Images = new List <MLibrary.MImage>(), IndexList = new List <int>(), Count = Images.Length }; for (int i = 0; i < library.Count; i++) { library.Images.Add(null); } ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; Parallel.For(0, Images.Length, options, i => { WTLImage image = Images[i]; if (image.HasMask) { library.Images[i] = new MLibrary.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow, MaskX = image.MaskX, MaskY = image.MaskY } } ; else { library.Images[i] = new MLibrary.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow } }; }); library.Save(); }
public void MergeToMLibrary(Mir3Library lib, int newImages) { int offset = lib.Images.Count; for (int i = 0; i < Images.Length; i++) { lib.Images.Add(null); } ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WTLImage image = Images[i]; WTLImage shadowimage = shadowLibrary != null ? shadowLibrary.Images[i] : null; if (shadowimage != null) { lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, shadowimage.Image, image.MaskImage) { OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow } } ; else { lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage) { OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow } }; }); lib.AddBlanks(newImages); } catch (System.Exception) { throw; } }
public void CheckMImage(int index) { if (!_initialized) Initialize(); if (index < 0 || index >= Images.Length) return; if (_indexList[index] == 0) { Images[index] = new WTLImage(); return; } WTLImage image = Images[index]; if (image == null) { _fStream.Seek(_indexList[index], SeekOrigin.Begin); image = new WTLImage(_bReader); Images[index] = image; image.CreateTexture(_bReader); } }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Zl"); if (File.Exists(fileName)) { File.Delete(fileName); } Mir3Library library = new Mir3Library(fileName) { Images = new List <Mir3Library.Mir3Image>() }; //library.Save(); library.Images.AddRange(Enumerable.Repeat(new Mir3Library.Mir3Image(), Images.Length)); ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WTLImage image = Images[i]; WTLImage shadowimage = shadowLibrary != null ? shadowLibrary.Images[i] : null; if (shadowimage != null && shadowimage.Length > 0) { library.Images[i] = new Mir3Library.Mir3Image(image.Image, shadowimage.Image, image.MaskImage) { OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = shadowimage.X, ShadowOffSetY = shadowimage.Y, ShadowType = shadowimage.Shadow } } ; else { library.Images[i] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage) { OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow } }; }); } catch (System.Exception) { throw; } finally { library.Save(fileName); } // Operation finished. // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.", // "Wemade Information", // System.Windows.Forms.MessageBoxButtons.OK, // System.Windows.Forms.MessageBoxIcon.Information, // System.Windows.Forms.MessageBoxDefaultButton.Button1); }
public void ToMLibrary() { string fileName = Path.ChangeExtension(_fileName, ".Lib"); if (File.Exists(fileName)) { File.Delete(fileName); } MLibraryV2 library = new MLibraryV2(fileName) { Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = Images.Length }; //library.Save(); for (int i = 0; i < library.Count; i++) { library.Images.Add(null); } ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; try { Parallel.For(0, Images.Length, options, i => { WTLImage image = Images[i]; if (image.HasMask) { library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow, MaskX = image.MaskX, MaskY = image.MaskY } } ; else { library.Images[i] = new MLibraryV2.MImage(image.Image) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow } }; }); } catch (System.Exception) { throw; } finally { library.Save(); } // Operation finished. // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.", // "Shanda Information", // System.Windows.Forms.MessageBoxButtons.OK, // System.Windows.Forms.MessageBoxIcon.Information, // System.Windows.Forms.MessageBoxDefaultButton.Button1); }