View Full Version : Resizing and reposition

January 23, 2007, 19:22:34

Thanks for the reply.

Following is snap of how we used to do it with DirectShow.Net:

// Get the IVideoWindow interface
videoWindow = (IVideoWindow) graphBuilder;

// Set the video window to be a child of the main window
hr = videoWindow.put_Owner( previewWindow.Handle );
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

// Set video window style
hr = videoWindow.put_WindowStyle( WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

// Position video window in client rect of owner window
previewWindow.Resize += new EventHandler( onPreviewWindowResize );
onPreviewWindowResize( this, null );

// Make the video window visible, now that it is properly positioned
hr = videoWindow.put_Visible( OABool.True);

/// <summary> Resize the preview when the PreviewWindow is resized </summary>
protected void onPreviewWindowResize(object sender, EventArgs e)
if ( videoWindow != null )
// Position video window in client rect of owner window
Rectangle rc = previewWindow.ClientRectangle;

// Keep aspect radio
// Some calculation go here
// ...
videoWindow.SetWindowPosition(x, y, w, h);
catch { }

Now comes my question:
To keep aspect radio, We need to know the width and height of the video format. Do ICCtrl.ImageWidth and ImageHeight give us the correct information? If not, how should we get this information?


Stefan Geissler
January 24, 2007, 08:19:10

Yes, IC gives you the correct video format width and height with:


If the size has not been changed, e.g. with the ROI frame filter, then these methods return the correct image resolution.

I hope, this helps. If not, please do not hesitate to ask me!

January 24, 2007, 15:01:30
Sorry, Stefan.

I did not make it clear. We are using the .Net Component in C#. See my email to you about the license issue.

icCtrl is an instance of ICImagingControl3.


Are these two properties that we should use to get the neccessary data?

.Net Framework 2.0
WindowsXP Pro

Stefan Geissler
January 25, 2007, 13:00:47

Indeed there are several methods available to retrieve the size of the video format:
for example:

What you have found.

Often it is hard for me to identify or guess the using programming language. I saw the "{" and concluded C++. Please excuse this.

March 9, 2007, 09:40:44
To using ROI I do this but it does'nt work, could you help me?
I think the problem is: smart_com<IFrameFilter> pROIFilter = FilterLoader::createFilter( "ROI" );


// Create an instance of the ROI filter, and let the user change the ROI
smart_com<IFrameFilter> pROIFilter = FilterLoader::createFilter( "ROI" );
pROIFilter->callDialog( 0 );
std::cout << "Setting video format: ";
// Set the filter, and call prepareLive.
gr.setDisplayFrameFilters( pROIFilter.get() );
gr.prepareLive( true );

// After prepareLive has been called, getVideoDataDimension returns the size of the
// live display.
SIZE dim;
if( gr.getVideoDataDimension( dim ) )
std::cout << "Display video format: " << dim.cx << "x" << dim.cy << std::endl;
std::cerr << "Unable to determine display video format" << std::endl;

Sascha Schmidt
March 9, 2007, 11:24:12

I guess, your source code snippet is from a function. This means that pROIFilter is deleted when you leave the function. In this case it will be deleted from the grabber too and you will get an access violation. Please make pROIFilter global, thus it will not deleted at the wrong point of time.