public static ImageProperty LoadProperty(IImageDecoder decoder, ImageTag property) { if (decoder == null) { throw new ArgumentNullException(); } PropertyItem item = new PropertyItem(); uint cbProp; decoder.GetPropertyItemSize(property, out cbProp); IntPtr pProp = Marshal.AllocHGlobal((int)cbProp); try { if (decoder.GetPropertyItem(property, cbProp, pProp) != 0) { return(null); } item = (PropertyItem)Marshal.PtrToStructure(pProp, typeof(PropertyItem)); return(LoadProperty(item)); } finally { Marshal.FreeHGlobal(pProp); } }