public static IWICMetadataQueryWriter CreateQueryWriter(this IWICImagingFactory imagingFactory, Guid guidMetadataFormat, Guid?pguidVendor = null) { using (var pguidVendorPtr = CoTaskMemPtr.From(pguidVendor)) { return(imagingFactory.CreateQueryWriter(guidMetadataFormat, pguidVendorPtr)); } }
public static IWICMetadataQueryWriter CreateQueryWriterFromReader(this IWICImagingFactory imagingFactory, IWICMetadataQueryReader pIQueryReader, Guid?pguidVendor = null) { using (var pguidVendorPtr = CoTaskMemPtr.From(pguidVendor)) { return(imagingFactory.CreateQueryWriterFromReader(pIQueryReader, pguidVendorPtr)); } }
public static IWICBitmapDecoder CreateDecoderFromStream(this IWICImagingFactory imagingFactory, IStream pIStream, WICDecodeOptions metadataOptions, Guid?pguidVendor = null) { using (var pguidVendorPtr = CoTaskMemPtr.From(pguidVendor)) { return(imagingFactory.CreateDecoderFromStream(pIStream, pguidVendorPtr, metadataOptions)); } }
public static IWICBitmapEncoder CreateEncoder(this IWICImagingFactory factory, Guid guidContainerFormat, Guid?pguidVendor = null) { using (var pguidVendorPtr = CoTaskMemPtr.From(pguidVendor)) { return(factory.CreateEncoder(guidContainerFormat, pguidVendorPtr)); } }
public static IWICBitmapDecoder CreateDecoderFromFilename(this IWICImagingFactory imagingFactory, string wzFilename, Guid?pguidVendor = null, WICDecodeOptions metadataOptions = WICDecodeOptions.WICDecodeMetadataCacheOnDemand) { using (var pguidVendorPtr = CoTaskMemPtr.From(pguidVendor)) { return(imagingFactory.CreateDecoderFromFilename(wzFilename, pguidVendorPtr, StreamAccessMode.GENERIC_READ, metadataOptions)); } }
public static void CopyPixels(this IWICBitmapSource bitmapSource, int cbStride, byte[] pbBuffer, WICRect?prc = null) { using (var prcPtr = CoTaskMemPtr.From(prc)) { bitmapSource.CopyPixels(prcPtr, cbStride, pbBuffer.Length, pbBuffer); } }
public static void WriteSource(this IWICBitmapFrameEncode bitmapFrameEncode, IWICBitmapSource pIBitmapSource, WICRect?prc = null) { using (var prcPtr = CoTaskMemPtr.From(prc)) { bitmapFrameEncode.WriteSource(pIBitmapSource, prcPtr); } }
public static IWICBitmapLock Lock(this IWICBitmap bitmap, WICBitmapLockFlags flags, WICRect?prcLock = null) { using (var prcLockPtr = CoTaskMemPtr.From(prcLock)) { return(bitmap.Lock(prcLockPtr, flags)); } }
public static WICBitmapPattern[] GetPatterns(this IWICBitmapDecoderInfo bitmapDecoderInfo) { int count; int size; bitmapDecoderInfo.GetPatterns(0, IntPtr.Zero, out count, out size); if (count == 0) { return(new WICBitmapPattern[0]); } using (var buffer = new CoTaskMemPtr(Marshal.AllocCoTaskMem(size))) { bitmapDecoderInfo.GetPatterns(size, buffer, out count, out size); IntPtr at = buffer; var patterns = new WICBitmapPattern[count]; for (int i = 0, stride = Marshal.SizeOf(typeof(WICBitmapPatternRaw)); i < count; ++i, at += stride) { var raw = (WICBitmapPatternRaw)Marshal.PtrToStructure(at, typeof(WICBitmapPatternRaw)); int length = raw.Length; patterns[i] = new WICBitmapPattern() { Length = length, Position = raw.Position, Pattern = new byte[length], Mask = new byte[length], EndOfStream = raw.EndOfStream }; Marshal.Copy(raw.Pattern, patterns[i].Pattern, 0, length); Marshal.Copy(raw.Mask, patterns[i].Mask, 0, length); } return(patterns); } }