RtfDomParser.RTFWriter.WriteBytes C# (CSharp) Method

WriteBytes() public method

write binary data
public WriteBytes ( byte bs ) : void
bs byte binary data
return void
        public void WriteBytes( byte[] bs )
        {
            if( bs == null || bs.Length == 0 )
                return ;
            WriteRaw( " " );
            for( int iCount = 0 ; iCount < bs.Length ; iCount ++ )
            {
                if( ( iCount % 32 ) == 0 )
                {
                    this.WriteRaw( System.Environment.NewLine );
                    this.WriteIndent();
                }
                else if( ( iCount % 8 ) == 0 )
                {
                    this.WriteRaw(" ");
                }
                byte b = bs[ iCount ] ;
                int h = ( b & 0xf0 ) >> 4  ;
                int l = b & 0xf ;
                myWriter.Write( Hexs[ h ] );
                myWriter.Write( Hexs[ l ] );
                intPosition += 2 ;
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// write image
        /// </summary>
        /// <param name="img">image</param>
        /// <param name="width">pixel width</param>
        /// <param name="height">pixel height</param>
        /// <param name="ImageData">image binary data</param>
        public void WriteImage(System.Drawing.Image img, int width, int height, byte[] ImageData)
        {
            if (this.bolCollectionInfo)
            {
                return;
            }
            else
            {
                if (ImageData == null)
                {
                    return;
                }

                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                ms.Close();
                byte[] bs = ms.ToArray();
                myWriter.WriteStartGroup();

                myWriter.WriteKeyword("pict");
                myWriter.WriteKeyword("jpegblip");
                myWriter.WriteKeyword("picscalex" + Convert.ToInt32(width * 100.0 / img.Size.Width));
                myWriter.WriteKeyword("picscaley" + Convert.ToInt32(height * 100.0 / img.Size.Height));
                myWriter.WriteKeyword("picwgoal" + Convert.ToString(img.Size.Width * 15));
                myWriter.WriteKeyword("pichgoal" + Convert.ToString(img.Size.Height * 15));
                myWriter.WriteBytes(bs);
                myWriter.WriteEndGroup();
            }
        }