H
H
Horoko2015-09-22 13:48:20
WPF
Horoko, 2015-09-22 13:48:20

How to show a bitmap continuously in an Image in WPF?

Subject. There is a method that receives WriteableBitmap as input (from the Kinect video stream), in the method, WriteableBitmap is converted to a regular Bitmap, then work is done with it, and at the output I convert it to BitmapSource. Actually, how can I continuously display this bitmap in an Image? DispatcherTimer terribly clogs memory. Are there any other ways?
ZY I'm new to c# and WPF, respectively.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
Horoko, 2015-09-23
@Horoko

Hung my Image<> in the ImageBox supplied by Emgu, and not in the WPF's Image. Now the memory does not fly away.

T
tex0, 2015-09-22
@tex0

ZY I'm new to c# and WPF, respectively.

Smoke towards the binding.
Image (if I'm not mistaken) has a Source property (the property type ImageSource.BitmapSource seems to be inherited from this type).
In CodeBehind define a property like this (BitmapContainer.cs)
class BitmapContainer : INotifyPropertyChanged
{
    public BitmapContainer()
    {
        //...
        DataContext = this; 
        //...
    }

private BitmapSource varBmpSrc_;

    public BitmapSource BmpSrc 
    {
        get
        {
            return varBmpSrc_;
        } 
        set
        { 
            varBmpSrc_ = value; 
            OnPropertyChanged("BmpSrc");//обязательно!!! Имплементить INotifyPropertyChanged интерфейс
        }
    }
}

Next in Markup (XAML) (BitmapContainer.cs.xaml)
...
    <Image Source={Binding BmpSrc, UpdateSourceTrigger=PropertyChanged} />
    ...

And further, in theory, when you set the BmpSrc property of an object of the BitmapContainer class, the Source property of the Image will change to a new one.
//где-то на просторах вашего кода
    bitmapContainerObject.BmpSrc = Converter(WriteableBitmap);

A
AxisPod, 2015-09-22
@AxisPod

It will not work normally, at least dig towards DirectShow, the processor will not pull your desires.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question