当前位置: 首页>>代码示例>>C#>>正文


C# FileStream.WriteByte方法代码示例

本文整理汇总了C#中System.IO.FileStream.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.WriteByte方法的具体用法?C# FileStream.WriteByte怎么用?C# FileStream.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileStream的用法示例。


在下文中一共展示了FileStream.WriteByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args) {
            if (args.Length != 1) {
                Console.WriteLine("Please provide a filename for the bitmap to convert.");
                return;
            }

            using (var bmp = new Bitmap(args[0])) {
                if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb) {
                    Console.WriteLine("Please provide a 24-bit depth bitmap to convert.");
                    return;
                }

                FileStream bin = new FileStream((string)(args[0] + ".24.bin"), FileMode.Create, FileAccess.Write);

                for (int row = 0; row < bmp.Height; row++) {
                    for (int column = 0; column < bmp.Width; column++) {
                        var pixel = bmp.GetPixel(column, row);
                        
                        // Convert from 888 to 565 format
                        ushort pixelOut = (byte) (pixel.R >> 3);
                        pixelOut <<= 6;
                        pixelOut |= (byte) (pixel.G >> 2);
                        pixelOut <<= 5;
                        pixelOut |= (byte) (pixel.B >> 3);

                        bin.WriteByte((byte) (pixelOut >> 8));
                        bin.WriteByte((byte) pixelOut);
                    }
                }
                bin.Close();
                Console.WriteLine("Done.");
            }
        }
开发者ID:aaronfisher,项目名称:x10ToSmartthings,代码行数:33,代码来源:Program.cs

示例2: convert

        /// <summary>
        /// Convert to 666 format
        /// </summary>
        public void convert(Bitmap bm, FileStream fs)
        {
            int x, y, r, g, b;
              Color c;

              for (y = 0; y < bm.Height; y++)
              {

            for (x = 0; x < bm.Width; x++)
            {

              c = bm.GetPixel(x, y);

              // convert to 666

              r = c.R & 0xFC;
              g = c.G & 0xFC;
              b = c.B & 0xFC;

              // the conversion is a tidy stream of bytes

              fs.WriteByte(Convert.ToByte(r));
              fs.WriteByte(Convert.ToByte(g));
              fs.WriteByte(Convert.ToByte(b));
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:30,代码来源:ILI9325AConverter262.cs

示例3: convert

        /// <summary>
        /// Do the conversion. 
        /// </summary>
        public void convert(Bitmap bm,FileStream fs)
        {
            int x,y;
              byte r,g,b;
              Color c;

              for(y=0;y<bm.Height;y++) {

            for(x=0;x<bm.Width;x++) {

              c=bm.GetPixel(x,y);

              // convert to 666

              r=(byte)(c.R & 0xFC);
              g=(byte)(c.G & 0xFC);
              b=(byte)(c.B & 0xFC);

              fs.WriteByte(b);
              fs.WriteByte(0);
              fs.WriteByte(r);
              fs.WriteByte(g);
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:28,代码来源:R61523Converter262.cs

示例4: SaveRegularGrid

        private void SaveRegularGrid(Grid grid, FileStream fs, StringBuilder bits)
        {
            fs.WriteByte(0);
#if LOG
            logger.AppendLine("Grid type : regular = 0");
#endif
            WriteGridProperties(grid, fs);

            bits.Append(grid.Cells[0].Alive ? '1' : '0');
            for (int i = 1; i < grid.Cells.Length; i++)
            {
                bits.Append(grid.Cells[i].Alive ? '1' : '0');

                if (i % sizeof(long) == 0)
                {
                    string binary = bits.ToString().Reverse();
                    byte octopus = Convert.ToByte(binary, 2);
                    fs.WriteByte(octopus);

#if LOG
                    logger.AppendLine("Bits { " + binary + " } = " + octopus);
#endif

                    bits.Clear();
                }
            }
        }
开发者ID:Chiheb2013,项目名称:game_of_life,代码行数:27,代码来源:GridStorageHelper.cs

示例5: WriteColor

 internal static void WriteColor(FileStream stream, Color color)
 {
     stream.WriteByte(color.A);
     stream.WriteByte(color.R);
     stream.WriteByte(color.G);
     stream.WriteByte(color.B);
 }
开发者ID:T-era,项目名称:PasswordManager,代码行数:7,代码来源:FileIo.cs

示例6: convert

        /// <summary>
        /// Do the conversion. 
        /// </summary>
        public void convert(Bitmap bm,FileStream fs)
        {
            int x,y,r,g,b,value;
              Color c;

              for(y=0;y<bm.Height;y++) {

            for(x=0;x<bm.Width;x++) {

              c=bm.GetPixel(x,y);

              // convert to 666

              r=c.R & 0xFC;
              g=c.G & 0xFC;
              b=c.B & 0xFC;

              value = r<<10;
              value |= g << 4;            // G into bits 6-11
              value |= b >> 2;            // B into bits 0-5

              fs.WriteByte((byte) (value >>16));
              fs.WriteByte(0);

              fs.WriteByte((byte) (value & 0xff));
              fs.WriteByte((byte) ((value >> 8) & 0xff));
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:32,代码来源:HX8352AConverter262.cs

示例7: WriteSubtitleBlock

 public static void WriteSubtitleBlock(FileStream fs, Paragraph p, int number)
 {
     fs.WriteByte(0);
     fs.WriteByte((byte)(number % 256)); // number - low byte
     fs.WriteByte((byte)(number / 256)); // number - high byte
     fs.WriteByte(0xff);
     fs.WriteByte(0);
     WriteTimeCode(fs, p.StartTime);
     WriteTimeCode(fs, p.EndTime);
     fs.WriteByte(1);
     fs.WriteByte(2);
     fs.WriteByte(0);
     var buffer = Encoding.GetEncoding(1252).GetBytes(p.Text.Replace(Environment.NewLine, "Š"));
     if (buffer.Length <= 128)
     {
         fs.Write(buffer, 0, buffer.Length);
         for (int i = buffer.Length; i < TextLength; i++)
         {
             fs.WriteByte(0x8f);
         }
     }
     else
     {
         for (int i = 0; i < TextLength; i++)
         {
             fs.WriteByte(buffer[i]);
         }
     }
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:29,代码来源:AvidStl.cs

示例8: WriteTimeCode

 private static void WriteTimeCode(FileStream fs, TimeCode tc)
 {
     fs.WriteByte((byte)(tc.Hours));
     fs.WriteByte((byte)(tc.Minutes));
     fs.WriteByte((byte)(tc.Seconds));
     fs.WriteByte((byte)(MillisecondsToFramesMaxFrameRate(tc.Milliseconds)));
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:7,代码来源:AvidStl.cs

示例9: convert

        /// <summary>
        /// Do the conversion. 
        /// </summary>
        public void convert(Bitmap bm,FileStream fs)
        {
            int x,y;

              byte red,green,blue;
              Color c;
              ushort first,second;

              for(y=0;y<bm.Height;y++) {

            for(x=0;x<bm.Width;x++) {

              c=bm.GetPixel(x,y);

              // convert to new format

              red=(byte)c.R;
              green=(byte)c.G;
              blue=(byte)c.B;

              first=(ushort)(((ushort)red << 4) | (green >> 4));
                second=(ushort)((((ushort)green & 0xf) << 8) | blue);

              fs.WriteByte((byte)(first & 0xff));
              fs.WriteByte((byte)(first >> 8));

              fs.WriteByte((byte)(second & 0xff));
              fs.WriteByte((byte)(second >> 8));
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:34,代码来源:SSD1963Converter16.cs

示例10: Save

        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <param name="subtitle">
        /// The subtitle.
        /// </param>
        public static void Save(string fileName, Subtitle subtitle)
        {
            FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);

            // header
            fs.WriteByte(1);
            for (int i = 1; i < 23; i++)
            {
                fs.WriteByte(0);
            }

            fs.WriteByte(0x60);

            // paragraphs
            int number = 0;
            foreach (Paragraph p in subtitle.Paragraphs)
            {
                WriteParagraph(p);
                number++;
            }

            // footer
            fs.WriteByte(0xff);
            for (int i = 0; i < 11; i++)
            {
                fs.WriteByte(0);
            }

            fs.WriteByte(0x11);
            byte[] footerBuffer = Encoding.ASCII.GetBytes("dummy end of file");
            fs.Write(footerBuffer, 0, footerBuffer.Length);

            fs.Close();
        }
开发者ID:KatyaMarincheva,项目名称:SubtitleEditOriginal,代码行数:43,代码来源:Spt.cs

示例11: convertRGB

        /// <summary>
        /// Convert to 565 format RGB
        /// </summary>
        public void convertRGB(Bitmap bm,FileStream fs)
        {
            int x,y,value,r,g,b;
              Color c;

              for(y=0;y<bm.Height;y++) {

            for(x=0;x<bm.Width;x++) {

              c=bm.GetPixel(x,y);

              // convert to 565

              r=c.R>>3;
              g=c.G>>2;
              b=c.B>>3;

              value=r<<11 | g<<5 | b;

              // little-endian output

              fs.WriteByte(Convert.ToByte(value & 0xFF));
              fs.WriteByte(Convert.ToByte(value >> 8));
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:29,代码来源:Generic565Converter.cs

示例12: ProcessBitmap

        public static void ProcessBitmap(string path) {
            using (var bmp = new Bitmap(path)) {
                if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb) {
                    Console.WriteLine("Please provide a 24-bit depth bitmap to convert.");
                    return;
                }

                var periodPosition = path.LastIndexOf('.');
                var filename = path.Substring(0, periodPosition);

                FileStream bin = new FileStream((string)(filename + ".bin"), FileMode.Create, FileAccess.Write);

                for (int row = 0; row < bmp.Height; row++) {
                    for (int column = 0; column < bmp.Width; column++) {
                        var pixel = bmp.GetPixel(column, row);
                        
                        // Convert from 888 to 565 format
                        ushort pixelOut = (byte) (pixel.R >> 3);
                        pixelOut <<= 6;
                        pixelOut |= (byte) (pixel.G >> 2);
                        pixelOut <<= 5;
                        pixelOut |= (byte) (pixel.B >> 3);

                        bin.WriteByte((byte) (pixelOut >> 8));
                        Console.Write("{0:x}", (byte)(pixelOut >> 8));
                        bin.WriteByte((byte) pixelOut);
                        Console.Write("{0:x}", (byte)pixelOut);
                    }
                    Console.Write("\r\n");
                }
                bin.Close();
                Console.WriteLine("Done.");
            }
        }
开发者ID:einart74,项目名称:NetduinoHelpers,代码行数:34,代码来源:Program.cs

示例13: MovieWriter

        public MovieWriter(string filepath, MovieId id, bool UseExistingFile)
        {
            file = new FileInfo(filepath);

            if (file.Exists && UseExistingFile)
            {
                using (FileStream input = new FileStream(filepath, FileMode.Open, FileAccess.Read))
                    fs = new FrameScanner(input);

                if (fs.HeaderOkay)
                    output = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite);
            }
            else
            {
                output = new FileStream(filepath, FileMode.Create, FileAccess.Write);
                output.Write(Encoding.ASCII.GetBytes("MMDb"), 0, 4);
                output.WriteByte((byte)FileVersions.First.Major);
                output.WriteByte((byte)FileVersions.First.Minor);
                output.Write(BitConverter.GetBytes(id.Id), 0, 4);
                output.Close();

                using (FileStream input = new FileStream(filepath, FileMode.Open, FileAccess.Read))
                    fs = new FrameScanner(input);

                output = new FileStream(filepath, FileMode.Open, FileAccess.Write);
            }
        }
开发者ID:Tonaplo,项目名称:DeadDog.Movies,代码行数:27,代码来源:MovieWriter.cs

示例14: Save

        public static void Save(string fileName, Subtitle subtitle)
        {
            using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                byte[] buffer = { 0x38, 0x35, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x30, 0x30, 0x30, 0x39 };
                fs.Write(buffer, 0, buffer.Length);
                for (int i = 0; i < 0xde; i++)
                    fs.WriteByte(0);
                string numberOfLines = subtitle.Paragraphs.Count.ToString("D5");

                buffer = Encoding.ASCII.GetBytes(numberOfLines + numberOfLines + "001");
                fs.Write(buffer, 0, buffer.Length);
                for (int i = 0; i < 0x15; i++)
                    fs.WriteByte(0);
                buffer = Encoding.ASCII.GetBytes("11");
                fs.Write(buffer, 0, buffer.Length);
                while (fs.Length < 1024)
                    fs.WriteByte(0);

                int subtitleNumber = 0;
                foreach (Paragraph p in subtitle.Paragraphs)
                {
                    WriteSubtitleBlock(fs, p, subtitleNumber);
                    subtitleNumber++;
                }
            }
        }
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:27,代码来源:AvidStl.cs

示例15: convert

        /// <summary>
        /// Do the conversion. 
        /// </summary>
        public void convert(Bitmap bm,FileStream fs)
        {
            int x,y;
              byte r,g,b,b1,b2;
              Color c;

              for(y=0;y<bm.Height;y++) {

            for(x=0;x<bm.Width;x++) {

              c=bm.GetPixel(x,y);

              // convert to 888

              r=(byte)(c.R & 0xf8);
              g=(byte)(c.G & 0xfc);
              b=(byte)(c.B & 0xf8);

              	  b1=(byte)(r | (g >> 5));
              	  b2=(byte)((g << 3) | (b >> 3));

              fs.WriteByte(b1);
              fs.WriteByte(b2);
            }
              }
        }
开发者ID:0x00f,项目名称:stm32plus,代码行数:29,代码来源:MC2PA8201Converter64.cs


注:本文中的System.IO.FileStream.WriteByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。