Пример #1
0
        public static IWICBitmap CreateBitmapFromBlob(this IWICImagingFactory factory, Array blob, int width, int height, int stride, Guid imageFormat)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (blob == null)
            {
                throw new ArgumentNullException("blob");
            }
            int        arrayBufferSize = WicUtility.GetArrayBufferSize(blob);
            IWICBitmap result;

            using (PinHelper pinHelper = new PinHelper(blob))
            {
                factory.CreateBitmapFromMemory(width, height, ref imageFormat, stride, arrayBufferSize, pinHelper.Addr, out result);
            }
            return(result);
        }
Пример #2
0
        public static void FillBlobFromBitmapSource(this IWICBitmapSource bitmap, Array blob)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("bitmap");
            }
            if (blob == null)
            {
                throw new ArgumentNullException("blob");
            }
            WICRect wicrect = default(WICRect);

            bitmap.GetSize(out wicrect.Width, out wicrect.Height);
            int arrayStride     = WicUtility.GetArrayStride(blob, wicrect.Width, wicrect.Height);
            int arrayBufferSize = WicUtility.GetArrayBufferSize(blob);

            using (PinHelper pinHelper = new PinHelper(blob))
            {
                bitmap.CopyPixels(ref wicrect, arrayStride, arrayBufferSize, pinHelper.Addr);
            }
        }