コード例 #1
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.CloneCore(Freezable)">Freezable.CloneCore</see>.
        /// </summary>
        protected override void CloneCore(Freezable sourceFreezable)
        {
            UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;

            base.CloneCore(sourceFreezable);

            CopyCommon(sourceBitmap);
        }
コード例 #2
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>.
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
        {
            UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;

            base.GetCurrentValueAsFrozenCore(sourceFreezable);

            CopyCommon(sourceBitmap);
        }
コード例 #3
0
        private void EnsureThumbnail()
        {
            if (_isThumbnailCached || IsDownloading)
            {
                return;
            }
            else
            {
                EnsureSource();

                IntPtr /* IWICBitmapSource */ thumbnail = IntPtr.Zero;

                lock (_syncObject)
                {
                    // Check if there is embedded thumbnail or not
                    int hr = UnsafeNativeMethods.WICBitmapFrameDecode.GetThumbnail(
                        _frameSource,
                        out thumbnail
                        );

                    if (hr != (int)WinCodecErrors.WINCODEC_ERR_CODECNOTHUMBNAIL)
                    {
                        HRESULT.Check(hr);
                    }
                }

                _isThumbnailCached = true;

                if (thumbnail != IntPtr.Zero)
                {
                    BitmapSourceSafeMILHandle thumbHandle      = new BitmapSourceSafeMILHandle(thumbnail);
                    SafeMILHandle             unmanagedPalette = BitmapPalette.CreateInternalPalette();
                    BitmapPalette             palette          = null;

                    int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
                        thumbHandle,
                        unmanagedPalette
                        );
                    if (hr == HRESULT.S_OK)
                    {
                        palette = new BitmapPalette(unmanagedPalette);
                    }

                    _thumbnail = new UnmanagedBitmapWrapper(
                        CreateCachedBitmap(
                            null,
                            thumbHandle,
                            BitmapCreateOptions.PreservePixelFormat,
                            _cacheOption,
                            palette
                            ));
                    _thumbnail.Freeze();
                }
            }
        }
コード例 #4
0
        private void EnsureThumbnail() 
        {
            if (_isThumbnailCached || IsDownloading) 
            {
                return;
            }
            else 
            {
                EnsureSource(); 
 
                IntPtr /* IWICBitmapSource */ thumbnail = IntPtr.Zero;
 
                lock (_syncObject)
                {
                    // Check if there is embedded thumbnail or not
                    int hr = UnsafeNativeMethods.WICBitmapFrameDecode.GetThumbnail( 
                        _frameSource,
                        out thumbnail 
                        ); 

                    if (hr != (int)WinCodecErrors.WINCODEC_ERR_CODECNOTHUMBNAIL) 
                    {
                        HRESULT.Check(hr);
                    }
                } 

                _isThumbnailCached = true; 
 
                if (thumbnail != IntPtr.Zero)
                { 
                    BitmapSourceSafeMILHandle thumbHandle = new BitmapSourceSafeMILHandle(thumbnail);
                    SafeMILHandle unmanagedPalette = BitmapPalette.CreateInternalPalette();
                    BitmapPalette palette = null;
 
                    int hr = UnsafeNativeMethods.WICBitmapSource.CopyPalette(
                                thumbHandle, 
                                unmanagedPalette 
                                );
                    if (hr == HRESULT.S_OK) 
                    {
                        palette = new BitmapPalette(unmanagedPalette);
                    }
 
                    _thumbnail = new UnmanagedBitmapWrapper(
                        CreateCachedBitmap( 
                            null, 
                            thumbHandle,
                            BitmapCreateOptions.PreservePixelFormat, 
                            _cacheOption,
                            palette
                            ));
                    _thumbnail.Freeze(); 
                }
            } 
        } 
コード例 #5
0
 private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap)
 {
     _bitmapInit.BeginInit();
     _bitmapInit.EndInit();
 }
コード例 #6
0
 private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap)
 {
     _bitmapInit.BeginInit();
     _bitmapInit.EndInit();
 }