I want to use capGetVideoFormat and capSetVideoFormat method in my application.
My code is
public class Class1
{
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
public void Init()
{
biSize = (uint)Marshal.SizeOf(this);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct RGBQUAD
{
public byte b;
public byte g;
public byte r;
public byte reserved;
}
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFO
{
public BITMAPINFOHEADER bmiHeader;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 1)]
public RGBQUAD[] bmiColors;
}
[StructLayout(LayoutKind.Sequential)]
public struct VIDEOHEADER
{
public IntPtr lpData;
public uint dwBufferLength;
public uint dwBytesUsed;
public uint dwTimeCaptured;
public uint dwUser;
public uint dwFlags;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.SafeArray)]
byte[] dwReserved;
}
public class Avicap32
{
[DllImport("avicap32.dll")]
public extern static IntPtr capGetDriverDescription(ushort index, StringBuilder name, int nameCapacity, StringBuilder description, int descriptionCapacity);
[DllImport("avicap32.dll")]
public extern static IntPtr capCreateCaptureWindow(string title, uint style, int x, int y, int width, int height, IntPtr window, int id);
[DllImport("avicap32.dll")]
public extern static bool capDriverGetName(IntPtr deviceHandle, StringBuilder Drivername, byte size);
[DllImport("avicap32.dll", EntryPoint = "capGetVideoFormat")]
public extern static UInt32 capGetVideoFormat(IntPtr deviceHandle,ref BITMAPINFO m_bitmapinfo, byte size);
[DllImport("avicap32.dll", EntryPoint = "capSetVideoFormat")]
public extern static bool capSetVideoFormat(IntPtr deviceHandle,ref BITMAPINFO m_bitmapinfo, byte size);
}
}
public class CaptureDevice
{
public void Attach(System.Windows.Forms.Control control)
{
deviceHandle = Class1.Avicap32.capCreateCaptureWindow("", Class1.Constants.WS_VISIBLE | Class1.Constants.WS_CHILD, 0, 0, control.Width, control.Height, control.Handle, 0);
Class1.BITMAPINFO bmi = new Class1.BITMAPINFO();
Class1.Avicap32.capGetVideoFormat(deviceHandle, ref bmi, wSize);
}
}
Exception is ' Unable to find an entry point named 'capGetVideoFormat' in DLL 'avicap32.dll'.'