public static void InitialDefaultTMOPng() { tmoms = new MemoryStream(); using (FileStream fs = File.OpenRead("SnapShotPose.tdcgpose.png")) { using (PNGPOSEStream posestream = new PNGPOSEStream()) { posedata = posestream.LoadStream(fs); // figureが何個だろうが必ず1個目. using (MemoryStream filetmo = new MemoryStream(posedata.figures[0].tmo.data)) { ZipFileUtil.CopyStream(filetmo, tmoms); } } } }
public void Dispose() { posedata = null; TDCGExplorer.GcCopact(); }
public PNGPoseData LoadStream(Stream stream) { posedata = new PNGPoseData(); try { PNGFile png = new PNGFile(); int fnum = 0; int flgt = 0; png.Hsav += delegate(string type) { // ここにはこない. }; png.Pose += delegate(string type) { posedata.scene = false; }; png.Scne += delegate(string type) { posedata.scene = true; }; png.Cami += delegate(Stream dest, int extract_length) { BinaryReader reader = new BinaryReader(dest, System.Text.Encoding.Default); posedata.camera = reader.ReadBytes(extract_length); }; png.Lgta += delegate(Stream dest, int extract_length) { if (flgt != 0) { fnum++; } posedata.figures.Add(new PNGPoseFigureData()); BinaryReader reader = new BinaryReader(dest, System.Text.Encoding.Default); posedata.figures[fnum].light = new PNGPoseLight(); posedata.figures[fnum].light.data = reader.ReadBytes(extract_length); flgt++; }; png.Figu += delegate(Stream dest, int extract_length) { BinaryReader reader = new BinaryReader(dest, System.Text.Encoding.Default); posedata.figures[fnum].data = reader.ReadBytes(extract_length); }; png.Ftmo += delegate(Stream dest, int extract_length) { BinaryReader reader = new BinaryReader(dest, System.Text.Encoding.Default); posedata.figures[fnum].tmo = new PNGPoseTmoData(); posedata.figures[fnum].tmo.data = reader.ReadBytes(extract_length); }; png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1) { PNGTsoData tsodata = new PNGTsoData(); // optionをuint32に変換する uint u32; unsafe { Marshal.Copy(opt1, 0, (IntPtr)(void *)&u32, sizeof(uint)); } Byte[] data; BinaryReader reader = new BinaryReader(dest, System.Text.Encoding.Default); data = reader.ReadBytes(extract_length); tsodata.tsoID = u32; tsodata.tsodata = data; posedata.figures[fnum].tsos.Add(tsodata); }; png.Load(stream); posedata.nfig = fnum + 1; } catch (Exception) { } return(posedata); }