public WicColorContext(object source) { if (source == null) { _comObject = WICImagingFactory.CreateColorContext(); } else if (source is IWICColorContext p) { _comObject = new ComObject <IWICColorContext>(p); } else if (source is uint colorSpace) { _comObject = WICImagingFactory.CreateColorContext(); _comObject.Object.InitializeFromExifColorSpace(colorSpace); } else if (source is string fileName) { _comObject = WICImagingFactory.CreateColorContext(); _comObject.Object.InitializeFromFilename(fileName); } else if (source is byte[] memory) { _comObject = WICImagingFactory.CreateColorContext(); _comObject.Object.InitializeFromMemory(memory, memory.Length); } else { _comObject = source as IComObject <IWICColorContext>; if (_comObject == null) { throw new ArgumentException("Source must be an " + nameof(IWICColorContext) + ".", nameof(source)); } } _profile = new Lazy <ColorProfile>(() => ColorProfile.FromMemory(ProfileBytes), true); }