The ChainedBitmap class is the base class for custom bitmaps that processes the content of another source.
The default implementation of the BitmapSource virtuals is to delegate to the source. This makes sense for most properties like DpiX, DpiY, PixelWidth, PixelHeight, etc, as in many scenarios these properties are the same for the entire chain of bitmap sources. However, derived classes should pay special attention to the Format property. Many bitmap processors only support a limited number of pixel formats, and they should return this for the Format property. ChainedBitmap will take care of converting the pixel format as needed in the base implementation of CopyPixels.
Inheritance: CustomBitmap
Esempio n. 1
0
        /// <summary>
        ///     Copies data into a cloned instance.
        /// </summary>
        /// <param name="original">
        ///     The original instance to copy data from.
        /// </param>
        /// <param name="useCurrentValue">
        ///     Whether or not to copy the current value of expressions, or the
        ///     expressions themselves.
        /// </param>
        /// <param name="willBeFrozen">
        ///     Indicates whether or not the clone will be frozen.  If the
        ///     clone will be immediately frozen, there is no need to clone
        ///     data that is already frozen, you can just share the instance.
        /// </param>
        /// <remarks>
        ///     Override this method if you have additional non-DP state that
        ///     should be transfered to clones.
        /// </remarks>
        protected override void CopyCore(CustomBitmap original, bool useCurrentValue, bool willBeFrozen)
        {
            ChainedBitmap originalChainedBitmap = (ChainedBitmap)original;

            if (originalChainedBitmap._formatConverter != null)
            {
                if (useCurrentValue)
                {
                    if (willBeFrozen)
                    {
                        _formatConverter = (FormatConvertedBitmap)originalChainedBitmap._formatConverter.GetCurrentValueAsFrozen();
                    }
                    else
                    {
                        _formatConverter = (FormatConvertedBitmap)originalChainedBitmap._formatConverter.CloneCurrentValue();
                    }
                }
                else
                {
                    if (willBeFrozen)
                    {
                        _formatConverter = (FormatConvertedBitmap)originalChainedBitmap._formatConverter.GetAsFrozen();
                    }
                    else
                    {
                        _formatConverter = (FormatConvertedBitmap)originalChainedBitmap._formatConverter.Clone();
                    }
                }
            }
        }
Esempio n. 2
0
        private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChainedBitmap chainedBitmap = (ChainedBitmap)d;

            chainedBitmap.OnSourcePropertyChanged(e);
        }