protected override void RunOverride(MainForm form, object tag) { bool info2Supported = false; IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IWICPixelFormatInfo2 info = null; try { info = factory.CreateComponentInfo(Parent.Clsid) as IWICPixelFormatInfo2; info2Supported = info != null; } finally { info.ReleaseComObject(); factory.ReleaseComObject(); } if (info2Supported) { ComponentInfoHelper.Check <IWICPixelFormatInfo2, object>(form, Parent.Clsid, Check, tag, this, false); } else { ComponentInfoHelper.Check <IWICPixelFormatInfo, object>(form, Parent.Clsid, Check, tag, this, false); } }
private void Check(MainForm form, IWICBitmapDecoderInfo info, Tag tag) { ComponentInfoHelper.CheckNotReserverdGuid(form, info.GetContainerFormat, this); tag.PixelFormats = PixelFormatInfoRule.CheckPixelFormats(form, this, info.GetPixelFormats); ComponentInfoHelper.CheckVersion(form, info.GetColorManagementVersion, this); ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetMimeTypes, ComponentInfoHelper.MimeMask, this); tag.Extensions = ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetFileExtensions, ComponentInfoHelper.ExtensionMask, this); if (!info.DoesSupportMultiframe() && info.DoesSupportAnimation()) { form.Add(this, Resources.DecoderAnimationIfMultiframe); } tag.SupportsMultiframe = info.DoesSupportMultiframe(); uint size = info.GetPatterns(0, IntPtr.Zero, out var count); if (size != 0) { IntPtr p = Marshal.AllocCoTaskMem((int)size); try { info.GetPatterns(size, p, out count); WICBitmapPattern[] patterns = PropVariantMarshaler.ToArrayOf <WICBitmapPattern>(p, (int)count); int index = 0; var dups = new HashSet <int>(); foreach (WICBitmapPattern pattern in patterns) { index++; if (pattern.Length == 0) { form.Add(this, Resources.PatternZeroLength, new DataEntry(Resources.PatternIndex, index)); } else if (index < patterns.Length) { if (Array.FindIndex(patterns, index, delegate(WICBitmapPattern obj) { return(obj.EndOfStream == pattern.EndOfStream && obj.Position == pattern.Position && GetNormalizedMask(obj).ItemsEqual(GetNormalizedMask(pattern))); }) >= 0) { dups.Add(index); } } } if (dups.Count > 0) { form.Add(this, Resources.PatternDuplicated, new DataEntry(Resources.PatternIndices, dups.ToArray())); } } finally { Marshal.FreeCoTaskMem(p); } } if (count == 0 || size == 0) { form.Add(this, Resources.PatternNo); } }
protected override void RunOverride(MainForm form, object tag) { Tag t = new Tag(); ComponentInfoHelper.Check <IWICBitmapDecoderInfo, Tag>(form, Parent.Clsid, Check, t, this, true); base.RunOverride(form, t); }
void Check(MainForm form, IWICBitmapEncoderInfo info, Tag tag) { ComponentInfoHelper.CheckNotReserverdGuid(form, info.GetContainerFormat, this); tag.PixelFormats = PixelFormatInfoRule.CheckPixelFormats(form, this, info.GetPixelFormats); ComponentInfoHelper.CheckVersion(form, info.GetColorManagementVersion, this); ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetMimeTypes, ComponentInfoHelper.MimeMask, this); tag.Extensions = ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetFileExtensions, ComponentInfoHelper.ExtensionMask, this); if (!info.DoesSupportMultiframe() && info.DoesSupportAnimation()) { form.Add(this, Resources.DecoderAnimationIfMultiframe); } tag.SupportsMultiframe = info.DoesSupportMultiframe(); }
protected override bool ProcessEncoder(MainForm form, IWICBitmapEncoder encoder, object tag) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IWICBitmap bitmap = factory.CreateBitmap(16, 16, Consts.GUID_WICPixelFormat32bppBGRA, WICBitmapCreateCacheOption.WICBitmapCacheOnLoad); IWICPalette palette = factory.CreatePalette(); palette.InitializePredefined(WICBitmapPaletteType.WICBitmapPaletteTypeFixedBW, false); IWICColorContext context = factory.CreateColorContext(); context.InitializeFromExifColorSpace(ExifColorSpace.sRGB); ComponentInfoHelper.CheckEquals <IWICBitmapEncoderInfo>(form, encoder.GetEncoderInfo, this, Extensions.CompareInfos); Check(form, encoder.SetPalette, palette); Check(form, encoder.SetThumbnail, bitmap); Check(form, encoder.SetPreview, bitmap); try { encoder.SetColorContexts(1, new IWICColorContext[] { context }); } catch (Exception e) { form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION, e); } try { encoder.Commit(); form.Add(this, string.Format(CultureInfo.CurrentUICulture, Resources._0_ShouldFail, "IWICBitmapEncoder::Commit(...)"), new DataEntry(Resources.FrameCount, 0)); } catch (Exception e) { form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_FRAMEMISSING, e, new DataEntry(Resources.FrameCount, 0)); } palette.ReleaseComObject(); bitmap.ReleaseComObject(); factory.ReleaseComObject(); context.ReleaseComObject(); return(base.ProcessEncoder(form, encoder, tag)); }
protected override void RunOverride(MainForm form, object tag) { IWICImagingFactory factory = (IWICImagingFactory) new WICImagingFactory(); IWICBitmapDecoderInfo info = (IWICBitmapDecoderInfo)factory.CreateComponentInfo(Parent.Clsid); Guid cf; info.GetContainerFormat(out cf); IWICBitmapDecoder decoder = null; try { decoder = info.CreateInstance(); Guid containerFormat; try { decoder.GetContainerFormat(out containerFormat); if (containerFormat != cf) { form.Add(this, Resources.ContainerFormatsDoNotMatch, new DataEntry(Resources.Actual, cf), new DataEntry(Resources.Expected, containerFormat)); } } catch (Exception e) { form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e)); } ComponentInfoHelper.CheckEquals <IWICBitmapDecoderInfo>(form, decoder.GetDecoderInfo, this, Extensions.CompareInfos); } finally { factory.ReleaseComObject(); info.ReleaseComObject(); decoder.ReleaseComObject(); } base.RunOverride(form, tag); }
protected override void RunOverride(MainForm form, object tag) { ComponentInfoHelper.Check <IWICFormatConverterInfo, object>(form, Parent.Clsid, Check, tag, this, true); }