コード例 #1
0
        private void init(Stream stream, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
        {
            // set gif frame update callback
            this.FrameUpdatedCallback = frameUpdatedCallback;

            // decode gif image
            var gifDecoder = new GifDecoder();
            var image      = new ExtendedImage();

            gifDecoder.Decode(image, stream);

            // add frames and load unity textures
            frames = new List <TextureGIFFrame>();
            var firstFrame = new TextureGIFFrame(createTexture(image.PixelWidth, image.PixelHeight, image.Pixels), TimeSpan.FromSeconds(image.DelayTime / 100d));

            frames.Add(firstFrame);
            var lastFrame = firstFrame;

            foreach (var frame in image.Frames)
            {
                var newFrame = new TextureGIFFrame(createTexture(frame.PixelWidth, frame.PixelHeight, frame.Pixels), TimeSpan.FromSeconds(frame.DelayTime / 100d));
                frames.Add(newFrame);
                if (lastFrame != null)
                {
                    lastFrame.nextFrame = newFrame;
                }
                lastFrame = newFrame;
            }

            // set starting image
            CurrentFrame        = frames[0];
            lastFrame.nextFrame = firstFrame;
        }
コード例 #2
0
 /// <summary>
 /// Construct gif from byte array
 /// </summary>
 /// <param name="data">Image data</param>
 /// <param name="frameUpdatedCallback">Called when gif frame texture has updated</param>
 public TextureGIF(byte[] data, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
 {
     using (var stream = new MemoryStream(data))
     {
         stream.Position = 0;
         init(stream, frameUpdatedCallback);
     }
 }
コード例 #3
0
		/// <summary>
		/// Construct gif from byte array
		/// </summary>
		/// <param name="data">Image data</param>
		/// <param name="frameUpdatedCallback">Called when gif frame texture has updated</param>
		public TextureGIF(byte[] data, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
		{
			using (var stream = new MemoryStream(data))
			{
				stream.Position = 0;
				init(stream, frameUpdatedCallback);
			}
		}
コード例 #4
0
		/// <summary>
		/// Construct gif from stream
		/// </summary>
		/// <param name="stream">Image Stream</param>
		/// <param name="frameUpdatedCallback">Called when gif frame texture has updated</param>
		public TextureGIF(Stream stream, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
		{
			init(stream, frameUpdatedCallback);
		}
コード例 #5
0
		private void init(Stream stream, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
		{
			// set gif frame update callback
			this.FrameUpdatedCallback = frameUpdatedCallback;

			// decode gif image
			var gifDecoder = new GifDecoder();
			var image = new ExtendedImage();
			gifDecoder.Decode(image, stream);

			// add frames and load unity textures
			frames = new List<TextureGIFFrame>();
			var firstFrame = new TextureGIFFrame(createTexture(image.PixelWidth, image.PixelHeight, image.Pixels), TimeSpan.FromSeconds(image.DelayTime / 100d));
			frames.Add(firstFrame);
			var lastFrame = firstFrame;
			foreach (var frame in image.Frames)
			{
				var newFrame = new TextureGIFFrame(createTexture(frame.PixelWidth, frame.PixelHeight, frame.Pixels), TimeSpan.FromSeconds(frame.DelayTime / 100d));
				frames.Add(newFrame);
				if (lastFrame != null) lastFrame.nextFrame = newFrame;
				lastFrame = newFrame;
			}

			// set starting image
			CurrentFrame = frames[0];
			lastFrame.nextFrame = firstFrame;
		}
コード例 #6
0
 /// <summary>
 /// Construct gif from stream
 /// </summary>
 /// <param name="stream">Image Stream</param>
 /// <param name="frameUpdatedCallback">Called when gif frame texture has updated</param>
 public TextureGIF(Stream stream, GIFFrameUpdatedCallbackMethod frameUpdatedCallback)
 {
     init(stream, frameUpdatedCallback);
 }