jamesmontemagno / GifImageView-Xamarin.Android

Animated ImageView for your Xamarin.Android apps
Other
24 stars 10 forks source link

Gif in drawable #1

Open dudus2000 opened 8 years ago

dudus2000 commented 8 years ago

I'm new and please help - how to insert "hook" to project a gif image from a folder drawable.

I'm sorry for the confusion but I found such a solution - but it does not work in Xamarin https://github.com/felipecsl/GifImageView/issues/12

kishoreconson-mobomo commented 6 years ago

Place the gif to be played in the raw folder

Stream gif = Resources.OpenRawResource(Resource.Raw.sample_gif);

we can easily get the byte array from the stream.

Alibesharat commented 5 years ago
        var stream = Resources.OpenRawResource(Resource.Drawable.sample_gif);
        var bytes = ReadAllBytes(stream);
        gifImageView.SetBytes(bytes);

        public  byte[] ReadAllBytes(Stream instream)
        {
                 if (instream is MemoryStream)
                 return ((MemoryStream)instream).ToArray();

               using (var memoryStream = new MemoryStream())
            {
                instream.CopyTo(memoryStream);
                return memoryStream.ToArray();
            }
        }