public static IEnumerable<KeyValuePair<Guid, string>> GetComponentInfoPairs(WICComponentType type, Remote remote) { HashSet<Guid> guids = new HashSet<Guid>(); foreach (IWICComponentInfo ci in GetComponentInfos(type)) { Guid clsid; ci.GetCLSID(out clsid); guids.Add(clsid); string s = Extensions.GetString(ci.GetFriendlyName); if (string.IsNullOrEmpty(s)) { s = string.Format(CultureInfo.CurrentUICulture, "CLSID: {0}", clsid); } yield return new KeyValuePair<Guid, string>(clsid, s); } if (remote != null) { foreach (var p in remote.GetComponentInfoPairs(type)) { if (!guids.Contains(p.Key)) { yield return p; } } } }
public AllComponentsRuleGroup(string text, WICComponentType type, Action <ComponentRuleGroup> childCreator, Remote remote) : base(text) { foreach (var p in GetComponentInfoPairs(type, remote)) { Nodes.Add(new ComponentRuleGroup(p.Key, p.Value, childCreator)); } }
public AllComponentsRuleGroup(string text, WICComponentType type, Action<ComponentRuleGroup> childCreator, Remote remote) : base(text) { foreach (var p in GetComponentInfoPairs(type, remote)) { Nodes.Add(new ComponentRuleGroup(p.Key, p.Value, childCreator)); } }
public virtual int GetComponentType( out WICComponentType pType ) { var fp = GetFunctionPointer(3); if (m_GetComponentTypeFunc == null) { m_GetComponentTypeFunc = (GetComponentTypeFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetComponentTypeFunc)); } return(m_GetComponentTypeFunc(m_ptr, out pType)); }
private static IEnumerable <IWICBitmapCodecInfo> EnumerateCodecs(WICComponentType type) { var wfac = (IWICImagingFactory) new WICImagingFactory(); wfac.CreateComponentEnumerator(type, 0, out var unks); if (unks != null) { var array = new object[1]; do { if (unks.Next(1, array, out var _) != 0) { break; } yield return((IWICBitmapCodecInfo)array[0]); }while (true); } }
private static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactoryCoClass(); IEnumUnknown eu = null; object[] o = new object[1]; try { eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateDefault); int hr = 0; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); Marshal.ThrowExceptionForHR(hr); if (fetched == 1) { IWICComponentInfo ci = (IWICComponentInfo)o[0]; try { yield return(ci); } finally { Marshal.ReleaseComObject(ci); } } } } finally { if (eu != null) { Marshal.ReleaseComObject(eu); } Marshal.ReleaseComObject(factory); } }
public static IEnumerable <IWICComponentInfo> GetComponentInfos(WICComponentType type) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IEnumUnknown eu = null; object[] o = new object[1]; try { eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateRefresh | WICComponentEnumerateOptions.WICComponentEnumerateDisabled); int hr = 0; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); Marshal.ThrowExceptionForHR(hr); if (fetched == 1) { IWICComponentInfo ci = (IWICComponentInfo)o[0]; try { yield return(ci); } finally { ci.ReleaseComObject(); } } } } finally { factory.ReleaseComObject(); eu.ReleaseComObject(); } }
private static IEnumerable <Guid> EnumerateFormatsForExtension(WICComponentType type, string extension) { if (extension == null) { throw new ArgumentNullException(nameof(extension)); } foreach (var info in EnumerateCodecs(type)) { info.GetFileExtensions(0, null, out var len); if (len >= 0) { var sb = new StringBuilder(len); info.GetFileExtensions(len + 1, sb, out _); var supportedExtensions = sb.ToString().Split(','); if (supportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) { if (info.GetContainerFormat(out var format) == 0) { yield return(format); } } } } }
public static IEnumerable<IWICComponentInfo> GetComponentInfos(WICComponentType type) { IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory(); IEnumUnknown eu = null; object[] o = new object[1]; try { eu = factory.CreateComponentEnumerator(type, WICComponentEnumerateOptions.WICComponentEnumerateRefresh | WICComponentEnumerateOptions.WICComponentEnumerateDisabled); int hr = 0; while (hr == 0) { uint fetched = 0; hr = eu.Next(1, o, ref fetched); Marshal.ThrowExceptionForHR(hr); if (fetched == 1) { IWICComponentInfo ci = (IWICComponentInfo)o[0]; try { yield return ci; } finally { ci.ReleaseComObject(); } } } } finally { factory.ReleaseComObject(); eu.ReleaseComObject(); } }
public void GetComponentType(out WICComponentType pType) { Log.Error("MetadataHandlerInfo.GetComponentType called"); throw new NotImplementedException(); }
public extern IEnumUnknown CreateComponentEnumerator([In] WICComponentType componentTypes, [In] WICComponentEnumerateOptions options);
public static IEnumerable <IComObject <IWICComponentInfo> > EnumerateComponents(this IWICImagingFactory factory, WICComponentType type, WICComponentEnumerateOptions options) { using (var enumerator = factory.CreateComponentEnumerator(type, options)) { do { var o = new object[1]; var fetched = 0; enumerator.Object.Next(1, o, ref fetched); if (fetched != 1) { break; } if (o[0] is IWICComponentInfo info) { yield return(new ComObject <IWICComponentInfo>(info)); } }while (true); } }
public static IComObject <IEnumUnknown> CreateComponentEnumerator(this IWICImagingFactory factory, WICComponentType type = WICComponentType.WICAllComponents, WICComponentEnumerateOptions options = WICComponentEnumerateOptions.WICComponentEnumerateDefault) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } factory.CreateComponentEnumerator(type, options, out var value).ThrowOnError(); return(new ComObject <IEnumUnknown>(value)); }
public static IComObject <IEnumUnknown> CreateComponentEnumerator(this IComObject <IWICImagingFactory> factory, WICComponentType type = WICComponentType.WICAllComponents, WICComponentEnumerateOptions options = WICComponentEnumerateOptions.WICComponentEnumerateDefault) => CreateComponentEnumerator(factory?.Object, type, options);
public KeyValuePair<Guid, string>[] GetComponentInfoPairs(WICComponentType type) { return AllComponentsRuleGroup.GetComponentInfoPairs(type, null).ToArray(); }
public KeyValuePair <Guid, string>[] GetComponentInfoPairs(WICComponentType type) { return(AllComponentsRuleGroup.GetComponentInfoPairs(type, null).ToArray()); }
public static IEnumerable <KeyValuePair <Guid, string> > GetComponentInfoPairs(WICComponentType type, Remote remote) { HashSet <Guid> guids = new HashSet <Guid>(); foreach (IWICComponentInfo ci in GetComponentInfos(type)) { Guid clsid; ci.GetCLSID(out clsid); guids.Add(clsid); string s = Extensions.GetString(ci.GetFriendlyName); if (string.IsNullOrEmpty(s)) { s = string.Format(CultureInfo.CurrentUICulture, "CLSID: {0}", clsid); } yield return(new KeyValuePair <Guid, string>(clsid, s)); } if (remote != null) { foreach (var p in remote.GetComponentInfoPairs(type)) { if (!guids.Contains(p.Key)) { yield return(p); } } } }