PDA

View Full Version : 'PixelFormat' is an ambiguous reference between 'System.Drawing.Imaging.PixelFormat'



WuWujo
08-14-2013, 08:27 PM
Hi
What could be wrong here?

'PixelFormat' is an ambiguous reference between 'System.Drawing.Imaging.PixelFormat' and 'OpenTK.Graphics.OpenGL.PixelFormat'
'System.Drawing.Imaging.PixelFormat' does not contain a definition for 'Bgr'

I do the same as in the example that works. For me it does not work.


GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, _texture.Width, _texture.Height, 0, PixelFormat.Bgr, PixelType.UnsignedByte, _texture.MIplImage.imageData);





private void View3DGlControl_Load(object sender, EventArgs e)
{
_glLoaded = true;

GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
SetupViewport();

#region Create texture for the 3D Point clouds
int repeat = (int)OpenTK.Graphics.OpenGL.All.Repeat;
int linear = (int)OpenTK.Graphics.OpenGL.All.Linear;
GL.Enable(EnableCap.CullFace);
GL.Enable(EnableCap.Texture2D);
_textures = new int[1];
GL.GenTextures(1, _textures);
GL.BindTexture(TextureTarget.Texture2D, _textures[0]);

/* GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, ref repeat);
GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, ref repeat);
GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, ref linear);
GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, ref linear);*/


GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, linear);


GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)OpenTK.Graphics.OpenGL.All.Decal);
GL.ShadeModel(ShadingModel.Smooth);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
GL.BindTexture(TextureTarget.Texture2D, 1);

Size size = _left.Size;
int maxDim = Math.Max(size.Width, size.Height);
using (Image<Bgr, Byte> squareImg = new Image<Bgr, byte>(maxDim, maxDim))
{
Rectangle roi = new Rectangle(maxDim / 2 - size.Width / 2, maxDim / 2 - size.Height / 2, size.Width, size.Height);
squareImg.ROI = roi;
CvInvoke.cvCopy(_left, squareImg, IntPtr.Zero);
squareImg.ROI = Rectangle.Empty;
_texture = squareImg.Resize(256, 256, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, true);
_texture._Flip(Emgu.CV.CvEnum.FLIP.VERTICAL);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, _texture.Width, _texture.Height, 0, PixelFormat.Bgr, PixelType.UnsignedByte, _texture.MIplImage.imageData);
}
#endregion

}

Thanks for reply.

GClements
08-14-2013, 08:47 PM
'PixelFormat' is an ambiguous reference between 'System.Drawing.Imaging.PixelFormat' and 'OpenTK.Graphics.OpenGL.PixelFormat'
This should be self-explanatory. Two different modules both define the name "PixelFormat", so it's ambiguous which one it refers to.

Replace any occurrences of "PixelFormat" with either "System.Drawing.Imaging.PixelFormat" or "OpenTK.Graphics.OpenGL.PixelFormat".



'System.Drawing.Imaging.PixelFormat' does not contain a definition for 'Bgr'

You use "PixelFormat.Bgr" which it interprets as "System.Drawing.Imaging.PixelFormat.Bgr" when you wanted "OpenTK.Graphics.OpenGL.PixelFormat.Bgr".

But beyond that, this is a general C# programming question, not an OpenGL question.

WuWujo
08-14-2013, 08:52 PM
Thanks. It's working