コード例 #1
0
        private static void CheckExtensionIntroducer(Stream s)
        {
            // check for extension introducer
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(GifComponent.CodeExtensionIntroducer, code);
        }
コード例 #2
0
        private static void CheckAppExtensionLabel(Stream s)
        {
            // check for app extension label
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(GifComponent.CodeApplicationExtensionLabel, code);
        }
コード例 #3
0
        private static void CheckEndOfStream(Stream s)
        {
            // check we're at the end of the stream
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(-1, code);
        }
コード例 #4
0
        private static void CheckBlockTerminator(Stream s)
        {
            // Check for block terminator after image data
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(0x00, code);
        }
コード例 #5
0
        private static void CheckGifTrailer(Stream s)
        {
            // check for GIF trailer
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(GifComponent.CodeTrailer, code);
        }
コード例 #6
0
        private static void CheckGraphicControlLabel(Stream s)
        {
            // check for gce label
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(GifComponent.CodeGraphicControlLabel, code);
        }
コード例 #7
0
        private static void CheckImageSeparator(Stream s)
        {
            // check for image separator
            int code = ExampleComponent.CallRead(s);

            Assert.AreEqual(GifComponent.CodeImageSeparator, code);
        }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        Profiler.BeginSample("ExampleComponent1");
        _exampleComponent1.DoSomething();
        Profiler.EndSample();

        Profiler.BeginSample("ExampleComponent2");
        _exampleComponent2 = exampleComponent2Go.GetComponent <ExampleComponent>();
        _exampleComponent2.DoSomething();
        Profiler.EndSample();
    }
コード例 #9
0
        private void OnEnable()
        {
            exampleComponent = target as ExampleComponent;
            if (!(exampleComponent is null))
            {
                exampleComponent.highlight += HighLightComponent;
            }

            editorType = GetType();
            StylesheetSetup();
        }
コード例 #10
0
        public void WikipediaExampleTest()
        {
            ReportStart();
            _e = new AnimatedGifEncoder();
            GifFrame frame = new GifFrame(WikipediaExample.ExpectedBitmap);

            frame.Delay = WikipediaExample.DelayTime;
            _e.AddFrame(frame);

            // TODO: some way of creating/testing a UseLocal version of WikipediaExample
            string fileName = "WikipediaExampleUseGlobal.gif";

            _e.WriteToFile(fileName);
            Stream s = File.OpenRead(fileName);

            int code;

            // check GIF header
            GifHeader gh = new GifHeader(s);

            Assert.AreEqual(ErrorState.Ok, gh.ConsolidatedState);

            // check logical screen descriptor
            LogicalScreenDescriptor lsd = new LogicalScreenDescriptor(s);

            Assert.AreEqual(ErrorState.Ok, lsd.ConsolidatedState);
            WikipediaExample.CheckLogicalScreenDescriptor(lsd);

            // read global colour table
            ColourTable gct
                = new ColourTable(s, WikipediaExample.GlobalColourTableSize);

            Assert.AreEqual(ErrorState.Ok, gct.ConsolidatedState);
            // cannot compare global colour table as different encoders will
            // produce difference colour tables.
//			WikipediaExample.CheckGlobalColourTable( gct );

            // check for extension introducer
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeExtensionIntroducer, code);

            // check for app extension label
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeApplicationExtensionLabel, code);

            // check netscape extension
            ApplicationExtension ae = new ApplicationExtension(s);

            Assert.AreEqual(ErrorState.Ok, ae.ConsolidatedState);
            NetscapeExtension ne = new NetscapeExtension(ae);

            Assert.AreEqual(ErrorState.Ok, ne.ConsolidatedState);
            Assert.AreEqual(0, ne.LoopCount);

            // check for extension introducer
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeExtensionIntroducer, code);

            // check for gce label
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeGraphicControlLabel, code);

            // check graphic control extension
            GraphicControlExtension gce = new GraphicControlExtension(s);

            Assert.AreEqual(ErrorState.Ok, gce.ConsolidatedState);
            WikipediaExample.CheckGraphicControlExtension(gce);

            // check for image separator
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeImageSeparator, code);

            // check for image descriptor
            ImageDescriptor id = new ImageDescriptor(s);

            Assert.AreEqual(ErrorState.Ok, id.ConsolidatedState);
            WikipediaExample.CheckImageDescriptor(id);

            // read, decode and check image data
            // Cannot compare encoded LZW data directly as different encoders
            // will create different colour tables, so even if the bitmaps are
            // identical, the colour indices will be different
            int pixelCount = WikipediaExample.FrameSize.Width
                             * WikipediaExample.FrameSize.Height;
            TableBasedImageData tbid = new TableBasedImageData(s, pixelCount);

            for (int y = 0; y < WikipediaExample.LogicalScreenSize.Height; y++)
            {
                for (int x = 0; x < WikipediaExample.LogicalScreenSize.Width; x++)
                {
                    int i = (y * WikipediaExample.LogicalScreenSize.Width) + x;
                    Assert.AreEqual(WikipediaExample.ExpectedBitmap.GetPixel(x, y),
                                    gct[tbid.Pixels[i]],
                                    "X: " + x + ", Y: " + y);
                }
            }

            // Check for block terminator after image data
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(0x00, code);

            // check for GIF trailer
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(GifComponent.CodeTrailer, code);

            // check we're at the end of the stream
            code = ExampleComponent.CallRead(s);
            Assert.AreEqual(-1, code);
            s.Close();

            _d = new GifDecoder(fileName);
            _d.Decode();
            Assert.AreEqual(ErrorState.Ok, _d.ConsolidatedState);
            BitmapAssert.AreEqual(WikipediaExample.ExpectedBitmap,
                                  (Bitmap)_d.Frames[0].TheImage,
                                  "");
            ReportEnd();
        }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     _exampleComponent1 = exampleComponent1Go.GetComponent <ExampleComponent>();
 }
コード例 #12
0
 // Use this for initialization
 void Start()
 {
     _exampleComponent = GetComponent <ExampleComponent>();
 }
コード例 #13
0
 public void TestComponentInstance()
 {
     _component = gameObject.AddComponent <ExampleComponent>();
     _running   = true;
 }