示例#1
0
文件: Program.cs 项目: ewxrjk/Defect
 static void Main(string[] args)
 {
     int width = int.Parse(args[0]);
       int height = int.Parse(args[1]);
       int colors = int.Parse(args[2]);
       string path = args[3];
       using (FileStream fs = new FileStream(path, FileMode.Create)) {
     GIF gif = new GIF()
     {
       Output = fs,
       ScreenWidth = width,
       ScreenHeight = height,
       GlobalColorTable = new GIF.ColorTable()
       {
     Table = new Color[colors],
       },
       Debug = true,
     };
     for(int n = 0; n < colors; ++n) {
       gif.GlobalColorTable.Table[n] = Color.FromArgb(n, n, n);
     }
     GIF.Image image = new GIF.Image()
     {
       ImageData = new byte[width * height],
     };
     for (int n = 0; n < image.ImageData.Length; ++n) {
       image.ImageData[n] = (byte)(n % colors);
     }
     gif.Begin();
     gif.WriteImage(image);
     gif.End();
     fs.Flush();
       }
 }
示例#2
0
文件: GIFTests.cs 项目: ewxrjk/Defect
 public void EmptyGifTest()
 {
     using (MemoryStream stream = new MemoryStream()) {
     GIF gif = new GIF()
     {
       Output = stream,
       ScreenWidth = 0,
       ScreenHeight = 0,
       GlobalColorTable = new GIF.ColorTable()
       {
     Table = new Color[2] { Color.White, Color.Black }
       }
     };
     gif.Begin();
     gif.WriteImage(new GIF.Image()
     {
       ImageData = new byte[0],
     });
     gif.End();
     int codeSize = 2;
     int clear = 1 << codeSize;
     int end = 1 + clear;
     TestUtils.AreEqual(new byte[] {
       // 0: Signature
       (byte)'G', (byte)'I', (byte)'F',(byte)'8', (byte)'9', (byte)'a',
       // 6: Logical screen descriptor
       0, 0,
       0, 0,
       0xF0,
       0,
       49,
       // 13: Global Color Table
       0xFF, 0xFF, 0xFF,
       0, 0, 0,
       // 19: Graphic control extension
       0x21, 0xF9, 0x04,
       1 << 2, 0, 0, 0,
       0,
       // 27: Image descriptor
       0x2C,
       0, 0,
       0, 0,
       0, 0,
       0, 0,
       0,
       // 37: Image data
       // 37: Minimum code size
       2,
       // 38: Data block
       1,
       (byte)(clear
          | (end << 3)),
       // 40: Block terminator
       0,
       // 41: Trailer
       0x3B
     }, stream.ToArray(), "EmptyGifTest");
       }
 }
示例#3
0
        private void InitializeRecording()
        {
            string path = FindUniqueFilename();

            RecordStream  = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); // TODO errors
            RecordContext = new GIF()
            {
                Output           = RecordStream,
                ScreenWidth      = Arena.Width * Scale,
                ScreenHeight     = Arena.Height * Scale,
                GlobalColorTable = GIFPalette,
                AutoClose        = true,
            };
            RecordPixels = new byte[Arena.Width * Arena.Height * Scale * Scale];
            RecordContext.Begin();
        }
示例#4
0
 private void ShutdownRecording()
 {
     RecordStream.Flush(); // TODO errors
       RecordStream.Dispose();
       RecordStream = null;
       RecordContext = null;
 }
示例#5
0
 private void InitializeRecording()
 {
     string path = FindUniqueFilename();
       RecordStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); // TODO errors
       RecordContext = new GIF()
       {
     Output = RecordStream,
     ScreenWidth = Arena.Width * Scale,
     ScreenHeight = Arena.Height * Scale,
     GlobalColorTable = GIFPalette,
     AutoClose = true,
       };
       RecordPixels = new byte[Arena.Width * Arena.Height * Scale * Scale];
       RecordContext.Begin();
 }