PDA

View Full Version : Resizing and reposition



zwzhang28
January 23, 2007, 20:22:34
Hi,

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
try
{
// 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?

Thanks

Stefan Geissler
January 24, 2007, 09:19:10
Hi,

Yes, IC gives you the correct video format width and height with:
Grabber::getAcqSizeMaxX()
http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_getAcqSizeMaxX.htm

and
Grabber::getAcqSizeMaxY()
http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_getAcqSizeMaxY.htm

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!

zwzhang28
January 24, 2007, 16: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.

icCtrl.ImageWidth
icCtrl.ImageHeiht

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

Again:
.Net Framework 2.0
VS2005
WindowsXP Pro
ICImagingControl3.Net

Stefan Geissler
January 25, 2007, 14:00:47
Hi,

Indeed there are several methods available to retrieve the size of the video format:
for example:
http://www.imagingcontrol.com/support/documentation/dotnet/VideoFormat.htm

What you have found.
http://www.imagingcontrol.com/support/documentation/dotnet/prop_descICImagingControl_ImageWidth.htm
http://www.imagingcontrol.com/support/documentation/dotnet/prop_descICImagingControl_ImageHeight.htm

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

Toan
March 9, 2007, 10: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" );




gr.showDevicePage();

// 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;
}
else
{
std::cerr << "Unable to determine display video format" << std::endl;
}

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

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.