Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to use capGetVideoFormat and capSetVideoFormat method in my application.

My code is
C#
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
        {
            // [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 1)]
            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
        {
/// <see cref="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_capgetdriverdescription.asp"/>
            [DllImport("avicap32.dll")]
            public extern static IntPtr capGetDriverDescription(ushort index, StringBuilder name, int nameCapacity, StringBuilder description, int descriptionCapacity);

            /// <see cref="http://msdn.microsoft.com/library/en-us/multimed/htm/_win32_capcreatecapturewindow.asp?frame=true"/>
            [DllImport("avicap32.dll")]
            public extern static IntPtr capCreateCaptureWindow(string title, uint style, int x, int y, int width, int height, IntPtr window, int id);
            /// <see cref="http://msdn.microsoft.com/library/en-us/multimed/htm/_win32_capcreatecapturewindow.asp?frame=true"/>
            [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'.'
Posted
Updated 11-Mar-13 23:25pm
v8

1 solution

avicap32.dll does not has capGetVideoFormat definition.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900