CVB.Net 15.0
Loading...
Searching...
No Matches

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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ BitmapSource()

BitmapSource ( Image source,
int maxDecodePixelWidth = 0,
int maxDecodePixelHeight = 0,
HighBitScaleMode highBitScaleMode = HighBitScaleMode::Default )

Creates a BitmapSource from the given source image.

Parameters
sourceSource image.
maxDecodePixelWidthMaximal decode pixel width; 0 for default.
maxDecodePixelHeightMaximal decode pixel height; 0 for default.
highBitScaleModeThe Cvb.HighBitScaleMode to use for non-8bpp images.

Member Function Documentation

◆ CloneCore()

override void CloneCore ( Freezable source)
protected

Copies data into a cloned instance.

Parameters
sourceThe 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.

◆ CloneCurrentValueCore()

override void CloneCurrentValueCore ( Freezable source)
protected

Copies data into a cloned instance.

Parameters
sourceThe 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.

◆ CopyPixels() [1/3]

override void CopyPixels ( Array pixels,
int stride,
int offset )

Requests pixels from this BitmapSource.

Parameters
pixelsThe destination array of pixels.
strideThe stride of the destination array.
offsetThe starting index within the destination array to copy to.

Derived classes must override CopyPixelsCore to implement custom logic.

◆ CopyPixels() [2/3]

override void CopyPixels ( Int32Rect sourceRect,
Array pixels,
int stride,
int offset )

Requests pixels from this BitmapSource.

Parameters
sourceRectThe rectangle of pixels to copy.
pixelsThe destination array of pixels.
strideThe stride of the destination array.
offsetThe starting index within the destination array to copy to.

Derived classes must override CopyPixelsCore to implement custom logic.

◆ CopyPixels() [3/3]

override void CopyPixels ( Int32Rect sourceRect,
IntPtr buffer,
int bufferSize,
int stride )

Requests pixels from this BitmapSource.

Parameters
sourceRectThe rectangle of pixels to copy.
bufferThe destination buffer of pixels.
bufferSizeThe size of the buffer, in bytes.
strideThe stride of the destination buffer.

Derived classes must override CopyPixelsCore to implement custom logic.

◆ CreateInstanceCore()

override Freezable CreateInstanceCore ( )
protected

Creates an instance of a CustomBitmap.

Returns
The new instance.

◆ GetAsFrozenCore()

override void GetAsFrozenCore ( Freezable source)
protected

Copies data into a cloned instance.

Parameters
sourceThe 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.

◆ GetCurrentValueAsFrozenCore()

override void GetCurrentValueAsFrozenCore ( Freezable source)
protected

Copies data into a cloned instance.

Parameters
sourceThe 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.

◆ RaiseDecodeFailed()

void RaiseDecodeFailed ( ExceptionEventArgs e)
protected

Raises the decode failed event.

Parameters
eException data.

Member Data Documentation

◆ HighBitScaleModeProperty

readonly DependencyProperty HighBitScaleModeProperty
static

Dependency property backing store of HighBitScaleMode.

This property can only be set between BeginInit and EndInit calls.

◆ MaxDecodePixelHeightProperty

readonly DependencyProperty MaxDecodePixelHeightProperty
static

Dependency property backing store for MaxDecodePixelHeight property.

This property can only be set between BeginInit and EndInit calls.

◆ MaxDecodePixelWidthProperty

readonly DependencyProperty MaxDecodePixelWidthProperty
static

Dependency property backing store for MaxDecodePixelWidth property.

This property can only be set between BeginInit and EndInit calls.

◆ SourceProperty

readonly DependencyProperty SourceProperty
static

Dependency property backing store for Source property.

This property can only be set between BeginInit and EndInit calls.

Property Documentation

◆ HighBitScaleMode

Sets the Cvb.HighBitScaleMode for scaling non-8bpp images.

This property can only be set between BeginInit and EndInit calls.

Default is HighBitScaleMode.Default.

◆ IsDownloading

override bool IsDownloading
get

Gets whether this bitmap source is downloading (never).

Always false.

◆ MaxDecodePixelHeight

int MaxDecodePixelHeight
getset

Gets/sets maximal decode height.

Decodes the Source image at this maximal resolution if unequal 0. If only one of the decode properties is set, the aspect ratio is preserved.

This property can only be set between BeginInit and EndInit calls.

0 is default and doesn't change the Source image.

◆ MaxDecodePixelWidth

int MaxDecodePixelWidth
getset

Gets/sets maximal decode width.

Decodes the Source image at this maximal resolution if unequal 0. If only one of the decode properties is set, the aspect ratio is preserved.

This property can only be set between BeginInit and EndInit calls.

0 is default and doesn't change the Source image.

◆ Palette

override System.Windows.Media.Imaging.BitmapPalette Palette
get

Palette of the bitmap.

Derived classes can override this to specify their own value. Default is null.

◆ Source

Image Source
getset

Gets/sets the Image source for this BitmapSource.

This property can only be set between BeginInit and EndInit calls.