This documentation is archived and is not being maintained.

CachedBitmap Class

Provides caching functionality for a BitmapSource.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public sealed class CachedBitmap : BitmapSource
You cannot directly create an instance of this class in XAML.

A BitmapSource does not cache bitmap data automatically. Using a CachedBitmap can improve performance in scenarios where multiple operations (such as clipping an image or scaling) need to be performed on a single bitmap.

The following code example shows how to create and use a CachedBitmap in code.

CachedBitmap cachedSource = new CachedBitmap(
    scaledSource, 
    BitmapCreateOptions.None,
    BitmapCacheOption.OnLoad);


// Create a new BitmapSource using a different format than the original one.
FormatConvertedBitmap newFormatSource = new FormatConvertedBitmap();
newFormatSource.BeginInit();
newFormatSource.Source = cachedSource;
newFormatSource.DestinationFormat = PixelFormats.Gray32Float;
newFormatSource.EndInit();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: