Esempio n. 1
0
        /// <summary>
        /// Creates a new collection of <see cref="HeifImage"/> from the specified data.
        /// </summary>
        /// <param name="input">The data to load the image from.</param>
        /// <returns>A new <see cref="HeifImage"/> instance.</returns>
        public static IHeifImageCollection DecodeCollection(byte[] input)
        {
            var result = new HeifImageCollection();

            HeifImageHandle?handle = null;

            try
            {
                using (var context = new HeifContext(input))
                {
                    foreach (var imageId in context.GetImageIds())
                    {
                        handle = new HeifImageHandle(context, imageId);

                        result.Add(new HeifImage(context, handle));
                    }
                }
            }
            catch
            {
                foreach (var image in result)
                {
                    image.Dispose();
                }

                handle?.Dispose();

                throw;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new collection of <see cref="HeifMetadata"/> from the specified data.
        /// </summary>
        /// <param name="input">The data to load the metadata from.</param>
        /// <returns>A new <see cref="HeifMetadata"/>.</returns>
        public static IReadOnlyCollection <HeifMetadata> GetCollectionMetadata(byte[] input)
        {
            using (var context = new HeifContext(input))
            {
                var result = new List <HeifMetadata>();
                foreach (var imageId in context.GetImageIds())
                {
                    using (var handle = new HeifImageHandle(context, imageId))
                    {
                        result.Add(handle.ToMetadata());
                    }
                }

                return(result);
            }
        }