BitmapSource for Image objects. More...
Public Member Functions | |
BitmapSource () | |
Creates an empty BitmapSource. | |
BitmapSource (Image source, int maxDecodePixelWidth=0, int maxDecodePixelHeight=0, HighBitScaleMode highBitScaleMode=HighBitScaleMode.Default) | |
Creates a BitmapSource from the given source image. | |
void | BeginInit () |
Begin the initialization phase. | |
void | EndInit () |
End the initialization phase and setup the object. | |
void | Dispose () |
Dispose this BitmapSource. | |
override void | CopyPixels (Array pixels, int stride, int offset) |
Requests pixels from this BitmapSource. | |
override void | CopyPixels (Int32Rect sourceRect, Array pixels, int stride, int offset) |
Requests pixels from this BitmapSource. | |
override void | CopyPixels (Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride) |
Requests pixels from this BitmapSource. | |
Static Public Attributes | |
static readonly DependencyProperty | HighBitScaleModeProperty |
Dependency property backing store of HighBitScaleMode. | |
static readonly DependencyProperty | MaxDecodePixelHeightProperty |
Dependency property backing store for MaxDecodePixelHeight property. | |
static readonly DependencyProperty | MaxDecodePixelWidthProperty |
Dependency property backing store for MaxDecodePixelWidth property. | |
static readonly DependencyProperty | SourceProperty |
Dependency property backing store for Source property. | |
Protected Member Functions | |
override Freezable | CreateInstanceCore () |
Creates an instance of a CustomBitmap. | |
override void | CloneCore (Freezable source) |
Copies data into a cloned instance. | |
override void | CloneCurrentValueCore (Freezable source) |
Copies data into a cloned instance. | |
override void | GetAsFrozenCore (Freezable source) |
Copies data into a cloned instance. | |
override void | GetCurrentValueAsFrozenCore (Freezable source) |
Copies data into a cloned instance. | |
void | RaiseDownloadCompleted () |
Raises the download completed event. | |
void | RaiseDecodeFailed (ExceptionEventArgs e) |
Raises the decode failed event. | |
Properties | |
HighBitScaleMode | HighBitScaleMode [get, set] |
Sets the Cvb.HighBitScaleMode for scaling non-8bpp images. | |
int | MaxDecodePixelHeight [get, set] |
Gets/sets maximal decode height. | |
int | MaxDecodePixelWidth [get, set] |
Gets/sets maximal decode width. | |
Image | Source [get, set] |
Gets/sets the Image source for this BitmapSource. | |
override PixelFormat | Format [get] |
The pixel format of this BitmapSource. | |
override int | PixelWidth [get] |
Gets the width of this BitmapSource in pixels. | |
override int | PixelHeight [get] |
Gets the height of this BitmapSource in pixels. | |
override double | DpiX [get] |
Horizontal DPI of the bitmap. | |
override double | DpiY [get] |
Vertical DPI of the bitmap. | |
override System.Windows.Media.Imaging.BitmapPalette | Palette [get] |
Palette of the bitmap. | |
override bool | IsDownloading [get] |
Gets whether this bitmap source is downloading (never). | |
Events | |
override EventHandler | DownloadCompleted [add, remove] |
Raised if the download is completed. | |
override EventHandler< ExceptionEventArgs > | DecodeFailed [add, remove] |
Raised if the Source could not be decoded. | |
BitmapSource for Image objects.
Attention:
do not use this class directly in any control displaying an image source. There is a bug in the WPF BitmapSource
implementation throwing a NotImplemented
exception in out of memory conditions in the render thread.
Makes CVB images accessible for WPF imaging. Resulting PixelFormats are either PixelFormats.Gray8 for single plane unsigned 8bpp image or PixelFormats.Bgr24 for all other formats (three plane 8bpp per plane images are also copied directly; all other formats are processed via the Image.ToBitmap
method.
As the WPF imaging model is only designed for still image support, you need to create a new BitmapSource each time you want to display an update. Update behavior is sadly hard-coded in WPF for just three BitmapSources: System.Windows.Media.Imaging.WriteableBitmap, System.Windows.Interop.InteropBitmap and System.Windows.Media.Imaging.RenderTargetBitmap. Creating new BitmapSource is designed to be cheap.
BitmapSource implementation based on the articles of Dwayne Need (http://social.msdn.microsoft.com/profile/dwayne%20need%20%5Bmsft%5D).
BitmapSource | ( | Image | source, |
int | maxDecodePixelWidth = 0, | ||
int | maxDecodePixelHeight = 0, | ||
HighBitScaleMode | highBitScaleMode = HighBitScaleMode::Default ) |
Creates a BitmapSource from the given source image.
source | Source image. |
maxDecodePixelWidth | Maximal decode pixel width; 0 for default. |
maxDecodePixelHeight | Maximal decode pixel height; 0 for default. |
highBitScaleMode | The Cvb.HighBitScaleMode to use for non-8bpp images. |
|
protected |
Copies data into a cloned instance.
source | The original instance to copy data from. |
When Freezable is cloned, WPF will make deep clones of all writable, locally-set properties including expressions. The property's base value is copied – not the current value. WPF skips read only DPs.
|
protected |
Copies data into a cloned instance.
source | The original instance to copy data from. |
When a Freezable's "current value" is cloned, WPF will make deep clones of the "current values" of all writable, locally-set properties. This has the effect of resolving expressions to their values. WPF skips read only DPs.
override void CopyPixels | ( | Array | pixels, |
int | stride, | ||
int | offset ) |
Requests pixels from this BitmapSource.
pixels | The destination array of pixels. |
stride | The stride of the destination array. |
offset | The starting index within the destination array to copy to. |
Derived classes must override CopyPixelsCore to implement custom logic.
override void CopyPixels | ( | Int32Rect | sourceRect, |
Array | pixels, | ||
int | stride, | ||
int | offset ) |
Requests pixels from this BitmapSource.
sourceRect | The rectangle of pixels to copy. |
pixels | The destination array of pixels. |
stride | The stride of the destination array. |
offset | The starting index within the destination array to copy to. |
Derived classes must override CopyPixelsCore to implement custom logic.
override void CopyPixels | ( | Int32Rect | sourceRect, |
IntPtr | buffer, | ||
int | bufferSize, | ||
int | stride ) |
Requests pixels from this BitmapSource.
sourceRect | The rectangle of pixels to copy. |
buffer | The destination buffer of pixels. |
bufferSize | The size of the buffer, in bytes. |
stride | The stride of the destination buffer. |
Derived classes must override CopyPixelsCore to implement custom logic.
|
protected |
Creates an instance of a CustomBitmap.
|
protected |
Copies data into a cloned instance.
source | The original instance to copy data from. |
Freezable.GetAsFrozen is semantically equivalent to Freezable.Clone().Freeze()
, except that you can avoid copying any portions of the Freezable graph which are already frozen.
|
protected |
Copies data into a cloned instance.
source | The original instance to copy data from. |
Freezable.GetCurrentValueAsFrozen is semantically equivalent to Freezable.CloneCurrentValue().Freeze()
, except that WPF will avoid copying any portions of the Freezable graph which are already frozen.
|
protected |
Raises the decode failed event.
e | Exception data. |
|
static |
Dependency property backing store of HighBitScaleMode.
This property can only be set between BeginInit and EndInit calls.
|
static |
Dependency property backing store for MaxDecodePixelHeight property.
This property can only be set between BeginInit and EndInit calls.
|
static |
Dependency property backing store for MaxDecodePixelWidth property.
This property can only be set between BeginInit and EndInit calls.
|
static |
|
getset |
Sets the Cvb.HighBitScaleMode for scaling non-8bpp images.
This property can only be set between BeginInit and EndInit calls.
Default is HighBitScaleMode.Default.
|
get |
Gets whether this bitmap source is downloading (never).
Always false
.
|
getset |
|
getset |
|
get |
Palette of the bitmap.
Derived classes can override this to specify their own value. Default is null
.
|
getset |
Gets/sets the Image source for this BitmapSource.
This property can only be set between BeginInit and EndInit calls.