Exemplo n.º 1
0
 internal static extern int                                                    /*HRESULT*/
 GetBitmap(
     SafeMILHandle /* IMILRenderTargetBitmap */ THIS_PTR,
     out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap);
Exemplo n.º 2
0
        // ISupportInitialize

        ///
        /// Create the unmanaged resources
        ///
        internal override void FinalizeCreation()
        {
            BitmapSourceSafeMILHandle wicClipper        = null;
            BitmapSourceSafeMILHandle wicTransformer    = null;
            BitmapSourceSafeMILHandle transformedSource = _unmanagedSource;

            HRESULT.Check(UnsafeNativeMethods.WICBitmap.SetResolution(_unmanagedSource, 96, 96));

            using (FactoryMaker factoryMaker = new FactoryMaker())
            {
                IntPtr wicFactory = factoryMaker.ImagingFactoryPtr;

                if (!_sourceRect.IsEmpty)
                {
                    HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapClipper(
                                      wicFactory,
                                      out wicClipper));

                    lock (_syncObject)
                    {
                        HRESULT.Check(UnsafeNativeMethods.WICBitmapClipper.Initialize(
                                          wicClipper,
                                          transformedSource,
                                          ref _sourceRect));
                    }

                    transformedSource = wicClipper;
                }

                if (_sizeOptions != null)
                {
                    if (_sizeOptions.DoesScale)
                    {
                        Debug.Assert(_sizeOptions.Rotation == Rotation.Rotate0);
                        uint width, height;

                        _sizeOptions.GetScaledWidthAndHeight(
                            (uint)_sizeOptions.PixelWidth,
                            (uint)_sizeOptions.PixelHeight,
                            out width,
                            out height);

                        HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapScaler(
                                          wicFactory,
                                          out wicTransformer));

                        lock (_syncObject)
                        {
                            HRESULT.Check(UnsafeNativeMethods.WICBitmapScaler.Initialize(
                                              wicTransformer,
                                              transformedSource,
                                              width,
                                              height,
                                              WICInterpolationMode.Fant));
                        }
                    }
                    else if (_sizeOptions.Rotation != Rotation.Rotate0)
                    {
                        HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateBitmapFlipRotator(
                                          wicFactory,
                                          out wicTransformer));

                        lock (_syncObject)
                        {
                            HRESULT.Check(UnsafeNativeMethods.WICBitmapFlipRotator.Initialize(
                                              wicTransformer,
                                              transformedSource,
                                              _sizeOptions.WICTransformOptions));
                        }
                    }

                    if (wicTransformer != null)
                    {
                        transformedSource = wicTransformer;
                    }
                }

                WicSourceHandle = transformedSource;

                // Since the original source is an HICON, HBITMAP or section, we know it's cached.
                // FlipRotate and Clipper do not affect our cache performance.
                _isSourceCached = true;
            }

            CreationCompleted = true;
            UpdateCachedSettings();
        }
Exemplo n.º 3
0
 internal static extern void GetBackBuffer(
     SafeMILHandle /* CSwDoubleBufferedBitmap */ THIS_PTR,
     out BitmapSourceSafeMILHandle /* IWICBitmap */ pBackBuffer,
     out uint pBackBufferSize
     );