Пример #1
0
 public static IWICBitmapLock Lock(this IWICBitmap bitmap, WICBitmapLockFlags flags, WICRect?prcLock = null)
 {
     using (var prcLockPtr = CoTaskMemPtr.From(prcLock))
     {
         return(bitmap.Lock(prcLockPtr, flags));
     }
 }
Пример #2
0
        public T WithLock <T>(WICBitmapLockFlags flags, Func <WicBitmapLock, T> func, WICRect?rect = null)
        {
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            using (var lck = CheckBitmap().Lock(flags, rect))
                return(func(new WicBitmapLock(lck)));
        }
Пример #3
0
        public void WithLock(WICBitmapLockFlags flags, Action <WicBitmapLock> action, WICRect?rect = null)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            using (var lck = CheckBitmap().Lock(flags, rect))
                action(new WicBitmapLock(lck));
        }
Пример #4
0
        public static IComObject <IWICBitmapLock> Lock(this IWICBitmap bitmap, WICBitmapLockFlags flags, WICRect?rect = null)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }

            using (var mem = new ComMemory(rect))
            {
                bitmap.Lock(mem.Pointer, flags, out var value).ThrowOnError();
                return(new ComObject <IWICBitmapLock>(value));
            }
        }
Пример #5
0
 public static IComObject <IWICBitmapLock> Lock(this IComObject <IWICBitmap> bitmap, WICBitmapLockFlags flags, WICRect?rect = null) => Lock(bitmap?.Object, flags, rect);