1

I am using the old webcam component file to stream a webcam video feed onto a Texture2D object.

I need help with the code as it is old and visual studio 2010 and XNA 4 does not recognize some of the syntax.

In the method BufferCB, the two lines that modify color are outdated. It says the "The type or namespace name Color does not exist in the namespace Microsoft.XNA.Framwork.Graphics (are you missing an assembly reference?)".

Here is the function:

public int BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
{
    byte[] bgrData = new byte[BufferLen];
    Marshal.Copy(pBuffer, bgrData, 0, BufferLen);
    Color[] colorData = new Color[BufferLen / 3];
    for (int i = 0; i < colorData.Length; i++)
    {
       colorData[i] = new Microsoft.Xna.Framework.Graphics.Color(bgrData[3 * i + 2], bgrData[3 * i + 1], bgrData[3 * i]);
    }
       this.videoTexture.SetData<Microsoft.Xna.Framework.Graphics.Color>(colorData);
            return 0;
 }

The line in the for loop and the line of code right after the for loop have the Color problem.

Also, how do I instantiate this class in my game class?

Any help would be great. Thanks

4

1 に答える 1

2

エラーは文字通り正確な問題を説明しています。

ColorXNA 4 の Microsoft.Xna.Framework 名前空間の一部です。参照: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.color%28v=xnagamestudio.35%29.aspx

Color4 つのコンストラクターを使用してインスタンス化できます。

Color color = new Color(r, g, b);(rgb は赤/緑/青の整数)

Color color = new Color(r, g, b);(ここで、rgb は赤/緑/青のフロートです)

Color color = new Color(r, g, b, a);(rgb は赤/緑/青/アルファの整数)

Color color = new Color(r, g, b, a);(ここで、rgb は赤/緑/青/アルファ フロートです)

于 2012-10-11T15:49:38.797 に答える