public override byte[] packMe() { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream()); writer.Write(message); writer.Write(bounced); return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer(); }
public override void BaseField_Leave(object sender, EventArgs e) { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(meta.MS); if (((WinMetaEditor)this.ParentForm).checkSelectionInCurrentTag()) bw.BaseStream.Position = this.offsetInMap - meta.offset; bw.Write((short)this.sidIndexer); bw.Write((byte) 0); bw.Write((byte)map.Strings.Length[this.sidIndexer]); /* // Check for typed value SID sid = (SID)(sender); if (sid.comboBox1.Text != map.Strings.Name[sid.sidIndexer]) { for (int i = 0; i < map.Strings.Name.Length; i++) if (map.Strings.Name[i].ToLower() == sid.comboBox1.Text.ToLower()) { sid.sidIndexer = i; break; } sid.comboBox1.Text = map.Strings.Name[sid.sidIndexer]; } */ //if (this.AutoSave) // this.Save(); }
public override byte[] packMe() { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream()); writer.Write(frompos); writer.Write(topos); return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer(); }
public void Save ( System.IO.Stream stream ) { var writer = new System.IO.BinaryWriter ( stream ); writer.Write (dict.Count); foreach (KeyValuePair<string,ZipEntry> pair in dict) { writer.Write (pair.Key); writer.Write (pair.Value.bytes.Length); writer.Write (pair.Value.bytes); } }
public override byte[] GetMessageBody() { System.IO.MemoryStream ms = new System.IO.MemoryStream (); System.IO.BinaryWriter bw = new System.IO.BinaryWriter (ms); bw.Write (userData.Length); foreach (var ud in userData) bw.Write (ud.GetMessageBody ()); return ms.ToArray (); }
public void SaveToFile(string fileName) { using(var writer = new System.IO.BinaryWriter(System.IO.File.OpenWrite(fileName))) { writer.Write(_header); writer.Write(_bytes); writer.Flush(); } }
// ***** Start pairing (play sound)***** private void button1_Click(object sender, EventArgs e) { if (clsHvcw.GenerateSound(textSSID.Text, textPassword.Text, txtToken) == true) { // Read sound file byte[] buf = System.IO.File.ReadAllBytes(clsHvcw.SoundFile); // Stop when sound playing if (player != null) StopSound(); player = new System.Media.SoundPlayer(); // Wav header definition WAVHDR wavHdr = new WAVHDR(); uint fs = 8000; wavHdr.formatid = 0x0001; // PCM uncompressed wavHdr.channel = 1; // ch=1 mono wavHdr.fs = fs; // Frequency wavHdr.bytespersec = fs * 2; // 16bit wavHdr.blocksize = 2; // 16bit mono so block size (byte/sample x # of channels) is 2 wavHdr.bitspersample = 16; // bit/sample wavHdr.size = (uint)buf.Length; // Wave data byte number wavHdr.fileSize = wavHdr.size + (uint)Marshal.SizeOf(wavHdr); // Total byte number // Play sound through memory stream System.IO.MemoryStream memoryStream = new System.IO.MemoryStream((int)wavHdr.fileSize); System.IO.BinaryWriter bWriter = new System.IO.BinaryWriter(memoryStream); // Write Wav header foreach (byte b in wavHdr.getByteArray()) { bWriter.Write(b); } // Write PCM data foreach (byte data in buf) { bWriter.Write(data); } bWriter.Flush(); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); player.Stream = memoryStream; // Async play player.Play(); // Wait until sound playing is over with following: // player.PlaySync(); } else { MessageBox.Show("Pairing sound creation failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override void calcbodysize() { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.MemoryStream()); bw.Write(generator); bw.Write(objectInformation.Count); for (int i = 0; i < objectInformation.Count; i++) { objectInformation[i].ToStream(bw); } camera.toStream(bw); size = Convert.ToInt32(bw.BaseStream.Length); }
public override void Save(string filename, Endogine.ColorEx.Palette palette) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate)); foreach (KeyValuePair<string, ColorEx.ColorBase> kv in palette) { //Vector4 v = color.VectorRGBA; System.Drawing.Color c = kv.Value.ColorRGBA; writer.Write((byte)(int)c.R); writer.Write((byte)(int)c.G); writer.Write((byte)(int)c.B); } }
public void MouseEvent(MouseEventFlags flags, int x, int y) { var messageStream = new System.IO.MemoryStream(); var messageWriter = new System.IO.BinaryWriter(messageStream); messageWriter.Write(0); messageWriter.Write((uint)flags); messageWriter.Write(x); messageWriter.Write(y); messageWriter.Write(0); SendMessage(messageStream.ToArray()); }
public override byte[] packMe() { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream()); writer.Write(players.Length); for (int i = 0; i < players.Length; i++) { writer.Write(players[i].color.ToArgb()); writer.Write(players[i].name); } return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer(); }
static public Guid CreateChannelID(Guid bcid, string channel_name, string genre, string source) { var stream = new System.IO.MemoryStream(); using (var writer = new System.IO.BinaryWriter(stream)) { var bcid_hash = System.Security.Cryptography.SHA512.Create().ComputeHash(bcid.ToByteArray()); writer.Write(bcid_hash); writer.Write(channel_name); writer.Write(genre); writer.Write(source); } var channel_hash = System.Security.Cryptography.MD5.Create().ComputeHash(stream.ToArray()); return new Guid(channel_hash); }
private void btnExport_Click(object sender, EventArgs e) { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Open("export.txt", System.IO.FileMode.Create)); bw.Write(width);//columns bw.Write(height);//rows for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { bw.Write(mapData[x, y]); } } bw.Close(); }
public bool ByteArrayToFile(string _FileName, byte[] _ByteArray) { try { // Open file for reading System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(_FileStream); // Writes a block of bytes to this stream using data from // a byte array. bw.Write(_ByteArray, 0, _ByteArray.Length); // close file stream bw.Close(); return true; } catch (Exception _Exception) { // Error Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()); } // error occured, return false return false; }
public static void PNGtoBIN(string path_in, string path_out, string[] param = null) { Image png = Image.FromFile(path_in); Bitmap bmp = new Bitmap(png); if ((png.Width != 128) && (png.Height != 32)) return; int tiles_w = png.Width / 4; int tiles_h = png.Height / 8; ushort[] binary = new ushort[256]; for (int y = 0; y < tiles_h; y++) { for (int x = 0; x < tiles_w; x++) { ushort[] tile = new ushort[2]; for (int iY = 0; iY < 8; iY++) { for (int iX = 0; iX < 4; iX++) { Color color = bmp.GetPixel(x * 4 + iX, y * 8 + iY); if (color.R + color.G + color.B > 0x0100) tile[(iY / 4)] |= (ushort)(1 << ((iY % 4) * 4 + iX)); } } binary[y * tiles_w * 2 + x * 2 + 0] = tile[0]; binary[y * tiles_w * 2 + x * 2 + 1] = tile[1]; } } System.IO.BinaryWriter writer = new System.IO.BinaryWriter(System.IO.File.Open(path_out, System.IO.FileMode.Create)); for (int i = 0; i < 256; i++) writer.Write(binary[i]); writer.Close(); }
public void Reset() { var messageStream = new System.IO.MemoryStream(); var messageWriter = new System.IO.BinaryWriter(messageStream); messageWriter.Write(1); SendMessage(messageStream.ToArray()); }
public void getPdfFile(string fileName) { using (SqlConnection cn = new SqlConnection(ConnectionString)) { cn.Open(); using (SqlCommand cmd = new SqlCommand($"select FileSource from PdfDocumentFiles where Name='{fileName}' ", cn)) { using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Default)) { if (dr.Read()) { byte[] fileData = (byte[])dr.GetValue(0); using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite)) { using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs)) { bw.Write(fileData); bw.Close(); } } } dr.Close(); } } } }
static void CreateSelfSignCertificate(CertOption option) { var fileName = option.CertFileName; var subject = option.Subject; var password = option.Password; try { var securePassword = Certificate.ConvertSecureString(password); var startDate = DateTime.Now; var endDate = startDate.AddYears(option.Years); var certData = Certificate.CreateSelfSignCertificatePfx(subject, startDate, endDate, securePassword); using (var writer = new System.IO.BinaryWriter(System.IO.File.Open(fileName, System.IO.FileMode.Create))) { writer.Write(certData); writer.Flush(); writer.Close(); } securePassword = Certificate.ConvertSecureString(password); } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// ファイルにデータをセーブ /// </summary> public static void SaveData() { using(var fs = System.IO.File.Open(@SAVEFILE,System.IO.FileMode.CreateNew)){ // バイナリライター作成 var bw = new System.IO.BinaryWriter(fs); // Write data bw.Write(Global.isStageOpened[(int)StageID.Stage1]); bw.Write(Global.isStageOpened[(int)StageID.Stage2]); bw.Write(Global.isStageOpened[(int)StageID.Stage3]); bw.Write(Global.characterLevel); bw.Write(Global.characterExp); bw.Close(); } }
public ByteBuffer(byte[] data) { stream = new System.IO.MemoryStream(); reader = new System.IO.BinaryReader(stream); writer = new System.IO.BinaryWriter(stream); writer.Write(data); stream.Position = 0; }
public static void Save(string directory, string file,string ext, XCImageCollection images) { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Create(directory+"\\"+file+ext)); foreach(XCImage tile in images) bw.Write(tile.Bytes); bw.Flush(); bw.Close(); }
public static byte[] SerializeVoxelAreaData (VoxelArea v) { #if !ASTAR_RECAST_CLASS_BASED_LINKED_LIST System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write (v.width); writer.Write (v.depth); writer.Write (v.linkedSpans.Length); for (int i=0;i<v.linkedSpans.Length;i++) { writer.Write(v.linkedSpans[i].area); writer.Write(v.linkedSpans[i].bottom); writer.Write(v.linkedSpans[i].next); writer.Write(v.linkedSpans[i].top); } //writer.Close(); writer.Flush(); Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(); stream.Position = 0; zip.AddEntry ("data",stream); System.IO.MemoryStream stream2 = new System.IO.MemoryStream(); zip.Save(stream2); byte[] bytes = stream2.ToArray(); stream.Close(); stream2.Close(); return bytes; #else throw new System.NotImplementedException ("This method only works with !ASTAR_RECAST_CLASS_BASED_LINKED_LIST"); #endif }
public static byte[] SerializeVoxelAreaData (VoxelArea v) { System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write (v.width); writer.Write (v.depth); writer.Write (v.linkedSpans.Length); for (int i=0;i<v.linkedSpans.Length;i++) { writer.Write(v.linkedSpans[i].area); writer.Write(v.linkedSpans[i].bottom); writer.Write(v.linkedSpans[i].next); writer.Write(v.linkedSpans[i].top); } //writer.Close(); writer.Flush(); Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(); stream.Position = 0; zip.AddEntry ("data",stream); System.IO.MemoryStream stream2 = new System.IO.MemoryStream(); zip.Save(stream2); byte[] bytes = stream2.ToArray(); stream.Close(); stream2.Close(); return bytes; }
public void WriteZippedResources() { using (var binWriter = new System.IO.BinaryWriter(this.fileSystem.File.OpenWrite(MyDhtmlResourceSet.ZippedResources.LocalPath))) { binWriter.Write(Properties.Resources.Pickles_BaseDhtmlFiles); binWriter.Flush(); binWriter.Close(); } }
public byte[] Serialize() { using (System.IO.MemoryStream MS = new System.IO.MemoryStream ()) { using (System.IO.BinaryWriter BW = new System.IO.BinaryWriter (MS, System.Text.Encoding.Unicode)) { BW.Write (connectionString); } return MS.ToArray (); } }
/// <summary> /// 将Base64编码字符串解码并存储到一个文件中 /// </summary> /// <param name="Base64String">经过Base64编码后的字符串</param> /// <param name="strSaveFileName">要输出的文件路径,如果文件存在,将被重写</param> /// <returns>如果操作成功,则返回True</returns> public static bool DecodingFileFromString(string Base64String, string strSaveFileName) { System.IO.FileStream fs = new System.IO.FileStream(strSaveFileName, System.IO.FileMode.Create); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs); bw.Write(Convert.FromBase64String(Base64String)); //bw.Write(Convert.ToBase64String) bw.Close(); fs.Close(); return true; }
public override byte[] packMe() { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream()); writer.Write(lobby.ptype[0]); writer.Write(lobby.ptype[1]); writer.Write(lobby.ptype[2]); writer.Write(lobby.ptype[3]); writer.Write(lobby.pname[0]); writer.Write(lobby.pname[1]); writer.Write(lobby.pname[2]); writer.Write(lobby.pname[3]); return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer(); }
public byte[] SerializeArray(object[] objects) { using (System.IO.MemoryStream MS = new System.IO.MemoryStream ()) { using (System.IO.BinaryWriter BW = new System.IO.BinaryWriter (MS)) { BW.Write (objects.Length); foreach (object obj in objects) { Serialize (obj, BW); } return MS.ToArray (); } } }
/// <summary>Write to a file </summary> //UPGRADE_TODO: Class 'java.io.RandomAccessFile' was converted to 'System.IO.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioRandomAccessFile'" public virtual void write(System.IO.FileStream raf) { System.IO.BinaryWriter temp_BinaryWriter; temp_BinaryWriter = new System.IO.BinaryWriter(raf); temp_BinaryWriter.Write((System.Int32) dwX); System.IO.BinaryWriter temp_BinaryWriter2; temp_BinaryWriter2 = new System.IO.BinaryWriter(raf); temp_BinaryWriter2.Write((System.Int32) dwY); System.IO.BinaryWriter temp_BinaryWriter3; temp_BinaryWriter3 = new System.IO.BinaryWriter(raf); temp_BinaryWriter3.Write((System.Int32) dwZ); }
public static void Assemble(string infile, string outfile, string origin) { CurrentNdx = 0; AsLength = Convert.ToUInt16(origin, 16); IsEnd = false; ExecutionAddress = 0; LabelTable = new System.Collections.Hashtable(50); System.IO.BinaryWriter output; System.IO.TextReader input; System.IO.FileStream fs = new System.IO.FileStream(outfile, System.IO.FileMode.Create); output = new System.IO.BinaryWriter(fs); input = System.IO.File.OpenText(infile); SourceProgram = input.ReadToEnd(); input.Close(); output.Write('B'); output.Write('3'); output.Write('2'); output.Write(Convert.ToUInt16(origin, 16)); output.Write((ushort)0); Parse(output, origin); output.Seek(5, System.IO.SeekOrigin.Begin); output.Write(ExecutionAddress); output.Close(); fs.Close(); }
protected override void WriteID(System.IO.BinaryWriter writer) { FormatChecker.CheckExpression(() => BlockSize == ExactBlockSize); writer.Write((int)Item.SpecialFolder); }
public RiffList(System.IO.Stream output, string fourCC, string id) : base(output, fourCC) { Writer = new System.IO.BinaryWriter(output); Writer.Write(ToFourCC(id)); this.Id = id; }
public void Pack(System.IO.BinaryWriter writer) { Key.Pack(writer); writer.Write(AddressID); }
public void Write(System.IO.Stream fileStream, int cubeIndex) { using (System.IO.BinaryWriter b = new System.IO.BinaryWriter(fileStream)) { b.Write(magic); b.Write(header.size); b.Write((uint)header.flags); b.Write(header.height); b.Write(header.width); b.Write(header.pitchOrLinearSize); b.Write(header.depth); b.Write(header.mipMapCount); foreach (uint u in header.reserved1) { b.Write(u); } b.Write(header.ddspf.size); b.Write((uint)header.ddspf.flags); b.Write(header.ddspf.fourCC); b.Write(header.ddspf.rGBBitCount); b.Write(header.ddspf.rBitMask); b.Write(header.ddspf.gBitMask); b.Write(header.ddspf.bBitMask); b.Write(header.ddspf.aBitMask); b.Write((uint)header.caps); b.Write((uint)header.caps2); b.Write(header.caps3); b.Write(header.caps4); b.Write(header.reserved2); if (header.ddspf.flags.HasFlag(DdsPixelFormat.Flags.DDPF_FOURCC) && header.ddspf.fourCC == 808540228) // DX10 { b.Write((uint)header10.dxgiFormat); b.Write((uint)header10.resourceDimension); b.Write(header10.miscFlag); b.Write(header10.arraySize); b.Write(header10.miscFlags2); } if (cubeIndex != -1) { b.Write(bdata2[cubeIndex]); } else if (bdata2 != null && bdata2.Count > 0) { for (int i = 0; i < bdata2.Count; i++) { if (bdata2.ContainsKey(i) == true) { b.Write(bdata2[i]); } } } else { b.Write(bdata); } } }
public override void SendExtraAI(System.IO.BinaryWriter writer) { writer.Write(this.target); }
internal override void WriteToStream(System.IO.BinaryWriter writer) { base.WriteToStream(writer); writer.Write(Resource.data); }
public void WriteTo(System.IO.BinaryWriter writer) { writer.Write(this.X); writer.Write(this.Y); }
public override void Serialize(System.IO.BinaryWriter aWriter) { aWriter.Write((byte)JSONNodeType.Boolean); aWriter.Write(m_Data); }
void UpdateGroundTruth(float3 _rho) { float4[][,] groundTruth = m_owner.GenerateGroundTruth(_rho, m_rotatedLightSH); if (groundTruth == m_lastGroundTruth) { return; // No change } m_lastGroundTruth = groundTruth; if (m_tex_GroundTruth != null) { m_tex_GroundTruth.Dispose(); } int slicesCount = groundTruth.Length; uint W = (uint)groundTruth[0].GetLength(0); uint H = (uint)groundTruth[0].GetLength(1); PixelsBuffer[] content = new PixelsBuffer[slicesCount]; for (int sliceIndex = 0; sliceIndex < slicesCount; sliceIndex++) { float4[,] sourceContent = groundTruth[sliceIndex]; PixelsBuffer sliceContent = new PixelsBuffer(W * H * 16); content[sliceIndex] = sliceContent; using (System.IO.BinaryWriter Wr = sliceContent.OpenStreamWrite()) { for (uint Y = 0; Y < H; Y++) { for (uint X = 0; X < W; X++) { Wr.Write(sourceContent[X, Y].x); Wr.Write(sourceContent[X, Y].y); Wr.Write(sourceContent[X, Y].z); Wr.Write(sourceContent[X, Y].w); } } } } m_tex_GroundTruth = new Texture2D(m_device, W, H, slicesCount, 1, PIXEL_FORMAT.RGBA32F, COMPONENT_FORMAT.AUTO, false, false, content); /* if ( m_tex_GroundTruth != null && _rho == m_groundTruthLastRho ) * return; // Already computed! * if ( m_indirectPixelIndices == null || m_imageNormal == null ) * return; * * m_groundTruthLastRho = _rho; * * if ( m_tex_GroundTruth != null ) * m_tex_GroundTruth.Dispose(); * m_tex_GroundTruth = null; * * uint W = m_width; * uint H = m_height; * uint X, Y, rayIndex, neighborIndex; * * float3[] rays = GeneratorForm.GenerateRays( (int) m_raysCount, Mathf.ToRad( 179.0f ) ); * float3 lsRayDirection, wsRayDirection; * float3 radiance = float3.Zero; * float3 irradiance = float3.Zero; * float3 T = float3.One, B = float3.One, N = float3.One; * * // IMPORTANT * _rho /= Mathf.PI; // We actually need rho/PI to integrate the radiance * // IMPORTANT * * * const int BOUNCES_COUNT = 20; * float3[][,] irradianceBounces = new float3[1+BOUNCES_COUNT][,]; * * * ////////////////////////////////////////////////////////////////////////// * // 1] Retrieve world normals * // * float3[,] normals = new float3[W,H]; * float3[,] tangents = new float3[W,H]; * float3[,] biTangents = new float3[W,H]; * m_imageNormal.ReadPixels( ( uint _X, uint _Y, ref float4 _color ) => { * N = new float3( 2.0f * _color.x - 1.0f, 2.0f * _color.y - 1.0f, 2.0f * _color.z - 1.0f ); * BuildOrthonormalBasis( N, ref T, ref B ); * normals[_X,_Y] = N; * tangents[_X,_Y] = T; * biTangents[_X,_Y] = B; * } ); * * * ////////////////////////////////////////////////////////////////////////// * // 2] Compute irradiance perceived directly * { * float3[,] E0 = new float3[W,H]; * irradianceBounces[0] = E0; * * float normalizer = 2.0f * Mathf.PI // This factor is here because are actually integrating over the entire hemisphere of directions * // and we only accounted for cosine-weighted distribution along theta, we need to account for phi as well! * / m_raysCount; * * neighborIndex = 0; * for ( Y=0; Y < H; Y++ ) { * for ( X=0; X < W; X++ ) { * T = tangents[X,Y]; * B = biTangents[X,Y]; * N = normals[X,Y]; * * irradiance = float3.Zero; * for ( rayIndex=0; rayIndex < m_raysCount; rayIndex++ ) { * uint packedNeighborPixelPosition = m_indirectPixelIndices[neighborIndex++]; * if ( packedNeighborPixelPosition != ~0U ) * continue; // Obstructed * * lsRayDirection = rays[rayIndex]; * wsRayDirection = lsRayDirection.x * T + lsRayDirection.y * B + lsRayDirection.z * N; * EvaluateSHRadiance( ref wsRayDirection, ref radiance ); * * irradiance += radiance * lsRayDirection.z; // L(x,Wi) * (N.Wi) * } * irradiance *= normalizer; * E0[X,Y] = irradiance; * } * } * } * * ////////////////////////////////////////////////////////////////////////// * // ] * PixelsBuffer content = new PixelsBuffer( W*H*4*4 ); * using ( System.IO.BinaryWriter Wr = content.OpenStreamWrite() ) { * for ( Y=0; Y < H; Y++ ) { * for ( X=0; X < W; X++ ) { * Wr.Write( irradianceBounces[0][X,Y].x ); * Wr.Write( irradianceBounces[0][X,Y].y ); * Wr.Write( irradianceBounces[0][X,Y].z ); * Wr.Write( 1 ); * } * } * } * m_tex_GroundTruth = new Texture2D( m_device, W, H, 1, 1, PIXEL_FORMAT.RGBA32F, COMPONENT_FORMAT.AUTO, false, false, new PixelsBuffer[] { content } ); */ }
public void Save(System.IO.BinaryWriter writer) { writer.Write(Text); }
public override void Serialize(System.IO.BinaryWriter aWriter) { aWriter.Write((byte)JSONNodeType.NullValue); }
public void Serialize(System.IO.BinaryWriter writer, MavLink4Net.Messages.IMessage message) { MavLink4Net.Messages.Common.GpsRtkMessage tMessage = message as MavLink4Net.Messages.Common.GpsRtkMessage; writer.Write(tMessage.TimeLastBaselineMs); writer.Write(tMessage.Tow); writer.Write(tMessage.BaselineAMm); writer.Write(tMessage.BaselineBMm); writer.Write(tMessage.BaselineCMm); writer.Write(tMessage.Accuracy); writer.Write(tMessage.IarNumHypotheses); writer.Write(tMessage.Wn); writer.Write(tMessage.RtkReceiverId); writer.Write(tMessage.RtkHealth); writer.Write(tMessage.RtkRate); writer.Write(tMessage.Nsats); writer.Write(((byte)(tMessage.BaselineCoordsType))); }
//変化があった場合のバイナリ書き込み protected virtual void WriteChanged(System.IO.BinaryWriter writer) { writer.Write(Target.activeSelf); BinaryUtil.WriteRectTransfom(RectTransform, writer); }
public static void saveTerrain(JsonTerrainData curTerrain, string targetDir, string projectPath, bool savePngs, Logger logger = null) { Logger.makeValid(ref logger); //logger.logFormat("Saving terrain {0}, {1}, {2}", targetDir, projectPath, curTerrain); if (curTerrain == null) { return; } var targetPath = System.IO.Path.Combine(targetDir, curTerrain.exportPath); // var dstDir = System.IO.Path.GetDirectoryName(targetPath); System.IO.Directory.CreateDirectory(dstDir); var heightPath = System.IO.Path.ChangeExtension(targetPath, ".height"); //logger.logFormat("Saving to \"{0}\", \"{1}\"", targetPath, heightPath); var terData = curTerrain.terrainData; #if UNITY_2019_3_OR_NEWER //heightmap api changed in this release int hMapW = terData.heightmapResolution; int hMapH = terData.heightmapResolution; #else int hMapW = terData.heightmapWidth; int hMapH = terData.heightmapHeight; #endif var numAlphas = terData.alphamapLayers; //logger.logFormat("w: {0}; h: {1}; alphas: {2}", w, h, numAlphas); var heightData = terData.GetHeights(0, 0, hMapW, hMapH); var alphaW = terData.alphamapWidth; var alphaH = terData.alphamapHeight; var alphaData = terData.GetAlphamaps(0, 0, alphaW, alphaH); var detailW = terData.detailWidth; var detailH = terData.detailHeight; var detailPrototypes = terData.detailPrototypes; var numDetailLayers = detailPrototypes.Length; //var numDetailLayers = terData.detailResolution; //binary map - all stuff combined together. using (var writer = new System.IO.BinaryWriter( System.IO.File.Open(targetPath, System.IO.FileMode.Create))){ writer.Write(hMapW); writer.Write(hMapH); writer.Write(alphaW); writer.Write(alphaH); writer.Write(numAlphas); writer.Write(detailW); writer.Write(detailH); writer.Write(numDetailLayers); //heightmap writeFloat2dBin(writer, hMapW, hMapH, heightData); //splats for (int alpha = 0; alpha < numAlphas; alpha++) { writeFloat3dSliceBin(writer, alphaW, alphaH, alpha, alphaData); } //detail layers for (var detLayer = 0; detLayer < numDetailLayers; detLayer++) { var detailData = terData.GetDetailLayer(0, 0, detailW, detailH, detLayer); writeInt2dBin(writer, detailW, detailH, detailData); } } //only height writeFloat2dBin(heightPath, hMapW, hMapH, heightData); saveFloat2dAsRawUint16(System.IO.Path.Combine(targetDir, curTerrain.heightMapRawPath), hMapW, hMapH, heightData, true ); /* * png height, debugging */ if (savePngs) { var pixels = new Color[hMapW * hMapH]; for (var y = 0; y < hMapH; y++) { var rowOffset = y * hMapH; for (var x = 0; x < hMapW; x++) { var f = heightData[y, x]; pixels[x + rowOffset] = new Color(f, f, f, 1.0f); } } var pngPath = heightPath + ".png"; TextureUtility.saveRawColorsToPng(pngPath, hMapW, hMapH, pixels, true); } //split splatmaps for (var alphaIndex = 0; alphaIndex < numAlphas; alphaIndex++) { var ext = string.Format(".alpha{0}", alphaIndex); var curAlphaPath = System.IO.Path.ChangeExtension(targetPath, ext); writeFloat3dSliceBin(curAlphaPath, alphaW, alphaH, alphaIndex, alphaData); saveFloat3dSliceAsRawUint8(System.IO.Path.Combine( targetDir, curTerrain.alphaMapRawPaths[alphaIndex] ), alphaW, alphaH, alphaIndex, alphaData, true ); //png splat if (savePngs) { var pngPath = curAlphaPath + ".png"; var pixels = new Color[alphaW * alphaH]; for (var y = 0; y < alphaH; y++) { var rowOffset = y * alphaH; for (var x = 0; x < alphaW; x++) { var f = alphaData[y, x, alphaIndex]; pixels[x + rowOffset] = new Color(f, f, f, 1.0f); } } TextureUtility.saveRawColorsToPng(pngPath, alphaW, alphaH, pixels, true); } } for (var detLayer = 0; detLayer < numDetailLayers; detLayer++) { var detailData = terData.GetDetailLayer(0, 0, detailW, detailH, detLayer); var ext = string.Format(".detail{0}", detLayer); var curDetailPath = System.IO.Path.ChangeExtension(targetPath, ext); writeInt2dBin(curDetailPath, detailW, detailH, detailData); writeInt2dBin(System.IO.Path.Combine(targetDir, curTerrain.detailMapRawPaths[detLayer]), detailW, detailH, detailData); if (savePngs) { var pngPath = curDetailPath + ".png"; var pixels = new Color[detailW * detailH]; for (var y = 0; y < detailH; y++) { var rowOffset = y * detailW; for (var x = 0; x < detailW; x++) { //those are ints? Apparently within 0..16 range? Sigh. float val = (float)detailData[y, x] / (float)15.0f; var c = new Color(val, val, val); pixels[x + rowOffset] = c; } } TextureUtility.saveRawColorsToPng(pngPath, detailW, detailH, pixels, true); } } }
/// <summary> /// バイナリデータ書き出し /// </summary> public virtual void Write(System.IO.BinaryWriter writer) { writer.Write((int)this.type); writer.Write(this.canMove); }
/// <summary> /// Saves a node to a stream recursively /// </summary> /// <param name="node">Node to save</param> /// <param name="sw">Reference to BinaryWriter</param> private void SaveNode(QuadTree node, ref System.IO.BinaryWriter sw) { //Write node boundingbox sw.Write(node.Box.Min.X); sw.Write(node.Box.Min.Y); sw.Write(node.Box.Max.X); sw.Write(node.Box.Max.Y); sw.Write(node.IsLeaf); if (node.IsLeaf) { sw.Write(node._objList.Count); //Write number of features at node for (int i = 0; i < node._objList.Count; i++) //Write each featurebox { sw.Write(node._objList[i].box.Min.X); sw.Write(node._objList[i].box.Min.Y); sw.Write(node._objList[i].box.Max.X); sw.Write(node._objList[i].box.Max.Y); sw.Write(node._objList[i].ID); } } else if (!node.IsLeaf) //Save next node { SaveNode(node.Child0, ref sw); SaveNode(node.Child1, ref sw); } }
/// <summary> /// バイナリデータ書き出し /// </summary> public override void Write(System.IO.BinaryWriter writer) { base.Write(writer); writer.Write(this.maxTime); writer.Write(this.time); }
public void Pack(System.IO.BinaryWriter writer) { writer.Write(Blob.Length); writer.Write(Blob); }
public override void BinaryWriteValue(System.IO.BinaryWriter writer, byte[] value) { writer.Write(value); }
public void Pack(System.IO.BinaryWriter writer) { writer.Write(FirstName); writer.Write(LastName); }
protected override void Serialize(System.IO.BinaryWriter writer) { writer.Write(id); writer.Write((uint)version); writer.Write(unknown); writer.Write(lotinstance); if ((int)version >= (int)FamiVersions.Business) { writer.Write(businesslot); } if ((int)version >= (int)FamiVersions.Voyage) { writer.Write(vacationlot); } if ((int)version >= (int)FamiVersions.Castaway) { writer.Write(ca_resources); writer.Write(ca_food); writer.Write(ca_food_decay); } else { writer.Write(strinstance); writer.Write(money); } writer.Write(friends); writer.Write((uint)this.Flags); writer.Write((uint)sims.Length); for (int i = 0; i < sims.Length; i++) { writer.Write((uint)sims[i]); } writer.Write(this.albumGUID); if ((int)version >= (int)FamiVersions.University) { writer.Write(this.subhood); } if ((int)version >= (int)FamiVersions.Castaway) { writer.Write(ca_resources); writer.Write(ca_food); writer.Write(ca_food_decay); } else if ((int)version >= (int)FamiVersions.Business) { writer.Write(businessmoney); } }
// Copied from https://stackoverflow.com/a/21389253/195833 private static Icon IconFromImage(Image img) { var ms = new System.IO.MemoryStream(); var bw = new System.IO.BinaryWriter(ms); // Header bw.Write((short)0); // 0 : reserved bw.Write((short)1); // 2 : 1=ico, 2=cur bw.Write((short)1); // 4 : number of images // Image directory var w = img.Width; if (w >= 256) { w = 0; } bw.Write((byte)w); // 0 : width of image var h = img.Height; if (h >= 256) { h = 0; } bw.Write((byte)h); // 1 : height of image bw.Write((byte)0); // 2 : number of colors in palette bw.Write((byte)0); // 3 : reserved bw.Write((short)0); // 4 : number of color planes bw.Write((short)0); // 6 : bits per pixel var sizeHere = ms.Position; bw.Write((int)0); // 8 : image size var start = (int)ms.Position + 4; bw.Write(start); // 12: offset of image data // Image data img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); var imageSize = (int)ms.Position - start; ms.Seek(sizeHere, System.IO.SeekOrigin.Begin); bw.Write(imageSize); ms.Seek(0, System.IO.SeekOrigin.Begin); // And load it return(new Icon(ms)); }
internal void SaveTo(System.IO.BinaryWriter bw) { bw.Write(this.LastProtocolSupportUpdate.ToBinary()); bw.Write((byte)this.ProtocolSupport); }
public void Serialize(System.IO.BinaryWriter writer, MavLink4Net.Messages.IMessage message) { MavLink4Net.Messages.Common.MessageIntervalMessage tMessage = message as MavLink4Net.Messages.Common.MessageIntervalMessage; writer.Write(tMessage.IntervalUs); writer.Write(tMessage.MessageId); }
private void writeFileContents(File f, System.IO.BinaryWriter bw) { bw.Write((int)f.fileSize); bw.Write(f.getContents()); }
private static void _saveByteCode(SASMCode _c) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream("bcode.bin", System.IO.FileMode.Create)); writer.Write(_c.Code); writer.Close(); }
public void Write(int value) { Writer.Write(value); }
public void Serialize(System.IO.BinaryWriter writer, MavLink4Net.Messages.IMessage message) { MavLink4Net.Messages.Common.HilOpticalFlowMessage tMessage = message as MavLink4Net.Messages.Common.HilOpticalFlowMessage; writer.Write(tMessage.TimeUsec); writer.Write(tMessage.IntegrationTimeUs); writer.Write(tMessage.IntegratedX); writer.Write(tMessage.IntegratedY); writer.Write(tMessage.IntegratedXgyro); writer.Write(tMessage.IntegratedYgyro); writer.Write(tMessage.IntegratedZgyro); writer.Write(tMessage.TimeDeltaDistanceUs); writer.Write(tMessage.Distance); writer.Write(tMessage.Temperature); writer.Write(tMessage.SensorId); writer.Write(tMessage.Quality); }
internal void FormHeader(ref System.IO.MemoryStream Header, BlockFormats fmt) { Header = new System.IO.MemoryStream(228); System.IO.BinaryWriter DWriter = new System.IO.BinaryWriter(Header); Header.Position = 0; switch (fmt) { case BlockFormats.fmt128x256: { DWriter.Write(Resources._128x256); break; } case BlockFormats.fmt128x128: { DWriter.Write(Resources._128x128); break; } case BlockFormats.fmt128x128mip: { DWriter.Write(Resources._128x128mip); break; } case BlockFormats.fmt128x64: { break; } case BlockFormats.fmt128x64mip: { DWriter.Write(Resources._128x64mip); break; } case BlockFormats.fmt128x32: { break; } case BlockFormats.fmt128x32mip: { DWriter.Write(Resources._128x32mip); break; } case BlockFormats.fmt64x64: { DWriter.Write(Resources._64x64); break; } case BlockFormats.fmt64x64mip: { DWriter.Write(Resources._64x64mip); break; } case BlockFormats.fmt64x32: { break; } case BlockFormats.fmt64x32mip: { DWriter.Write(Resources._64x32mip); break; } case BlockFormats.fmt32x64: { DWriter.Write(Resources._32x64); break; } case BlockFormats.fmt32x64mip: { DWriter.Write(Resources._32x64mip); break; } case BlockFormats.fmt32x32: { break; } case BlockFormats.fmt32x32mip: { DWriter.Write(Resources._32x32mip); break; } case BlockFormats.fmt32x16: { break; } case BlockFormats.fmt32x16mip: { DWriter.Write(Resources._32x16mip); break; } case BlockFormats.fmt32x8: { DWriter.Write(Resources._32x8); break; } case BlockFormats.fmt16x16: { break; } case BlockFormats.fmt16x16mip: { DWriter.Write(Resources._16x16mip); break; } } }
public override void BinaryWriteValue(System.IO.BinaryWriter writer, string value) { writer.Write(value); }