/// <summary> /// 指定パスからPNGFileを読み込みフィギュアを作成します。 /// </summary> /// <param name="source_file">PNGFileのパス</param> public void LoadPNGFile(Stream stream) { try { PNGFile png = new PNGFile(); png.Hsav += delegate(string type) { }; png.Lgta += delegate(Stream dest, int extract_length) { }; png.Ftmo += delegate(Stream dest, int extract_length) { }; png.Figu += delegate(Stream dest, int 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; tsoData.Add(tsodata); }; png.Load(stream); } catch (Exception ex) { Console.WriteLine("Error: " + ex); } }
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); }