View Full Version : WPF Support

November 23, 2009, 18:52:33
I would like to use the control in a WPF app. I would like to grab the images from the buffer and display them in a WPF Canvas.

However, when I add the reference "AxInterop.ICImagingControl3.dll" the WPF designer reports the following exception: "String was not recognized as a valid DateTime."

Apparently, there is a bug in the AxImp.exe tool as can be read about here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338575

Can you regenerate a new Ax Interop file so that we can use the control in WPF apps?

Stefan Geissler
November 24, 2009, 09:18:51

I never worked with WPF before, but I guess, this worked with IC 3.0. However, I suggest to update for free to IC 3.1 to make things easier. Please contact me at http://www.imagingcontrol.com/en_US/support/case/

December 15, 2009, 13:52:40
Hi there, I would also require this. I have made a work around, but you cannot guarantee true PAL or NTSC framerate, it will vary with the CPU speed.

To get around I used something like this, within the ImageAvailable event handler:

// create stream
Stream bitmapStream = new MemoryStream();

// save to stream
e.ImageBuffer.Bitmap.Save(bitmapStream, ImageFormat.Png);

// create frame
BitmapFrame frame = BitmapFrame.Create(bitmapStream);

// set current image to a locally stored frame
this.Dispatcher.BeginInvoke(new LambdaCallerEventHandler(() => this.CurrentFrame = frame), DispatcherPriority.Send);

And then binded my images source to the this.CurrentFrame property (which was setup as a dependency property to allow binding update notifications).

For a canvas you would want to set the image held in the CurrentFrame property (or wherever you are storing the frame created by the stream in the code above) to the background of the canvas. You could do this by either:

Using a visual brush:

<VisualBrush Visual="{Binding ElementName=CurrentFrame}"/>

Or using an image brush:

<ImageBrush ImageSource="{Binding Path=CurrentFrame}"/>

To get this to work you also need to set the property LiveDisplay to false, and LiveCaptureContinuous to true onthe ICImagingControl property.

This by no means ideal, but it is the best solution I have found to use the ICImagingControl in WPF. Ofcourse you could use directshow to pull the image urself...