I use unmanaged libraries to obtain video stream from IP Camera. There is function:
[DllImport("client.dll", EntryPoint = "Network_ClientStartLive", SetLastError = true)]
protected static extern int Network_ClientStartLive(
ref IntPtr pStream,
IntPtr hDev,
IntPtr pClientInfo,
[MarshalAs(UnmanagedType.FunctionPtr)] ReadDatacbf lpfnCallbackFunc = null,
UInt32 dwUserData = 0
);
The pClientInfo is a pointer to structure type of:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
protected struct LiveConnect
{
public UInt32 dwChannel;
public IntPtr hPlayWnd;
public UInt32 dwConnectMode;
}
where hPlayWnd is a handle of window in which video stream must be output.
The library detects the video resolution by size of this window (during the call to Network_ClientStartLive). I checked it on C++ MFC program, where output window is Picture control and by setting size with method MoveWindow was defined output video resolution.
In the C# version of this program I'm using a PictureBox-control to draw the video stream. The video is displayed but the size of the PictureBox does not affect to video stream resolution. I tried several methods to change PictureBox size:
- setting
pictureBox.Size - using WinAPI
SetWindowPos:
[DllImport("user32.dll")]
private static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int x,
int y,
int width,
int height,
uint uFlags);
In both methods the size of the control was changed but the camera library continued to output video stream in maximum resolution.
How can I solve this problem?
Thanks!