/// <summary> /// Gets a list of the meta-data block ids. /// </summary> /// <param name="type">The meta-data block type.</param> /// <param name="contentType">The meta-data block content type.</param> /// <returns>A list of the meta-data block ids.</returns> /// <exception cref="HeifException">Could not get all of the meta-data block ids.</exception> /// <exception cref="ObjectDisposedException">The object has been disposed.</exception> public IReadOnlyList <HeifItemId> GetMetadataBlockIds(string type = null, string contentType = null) { VerifyNotDisposed(); int count = LibHeifNative.heif_image_handle_get_number_of_metadata_blocks(this.imageHandle, type); if (count == 0) { return(Array.Empty <HeifItemId>()); } var ids = new HeifItemId[count]; unsafe { fixed(HeifItemId *ptr = ids) { int filledCount = LibHeifNative.heif_image_handle_get_list_of_metadata_block_IDs(this.imageHandle, type, ptr, count); if (filledCount != count) { ExceptionUtil.ThrowHeifException(Resources.CannotGetAllMetadataBlockIds); } } } // The type must be defined in order to filter by content type. if (type != null && contentType != null) { var matchingItems = new List <HeifItemId>(); for (int i = 0; i < ids.Length; i++) { var id = ids[i]; var metadataContentType = LibHeifNative.heif_image_handle_get_metadata_content_type(this.imageHandle, id); if (contentType.Equals(metadataContentType.GetStringValue(), StringComparison.Ordinal)) { matchingItems.Add(id); } } return(matchingItems); } else { return(ids); } }