Results 1 to 3 of 3

Thread: 'PixelFormat' is an ambiguous reference between 'System.Drawing.Imaging.PixelFormat'

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2013
    Posts
    4

    'PixelFormat' is an ambiguous reference between 'System.Drawing.Imaging.PixelFormat'

    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.
    Code :
    GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, _texture.Width, _texture.Height, 0, PixelFormat.Bgr, PixelType.UnsignedByte, _texture.MIplImage.imageData);

    Code :
           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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,104
    Quote Originally Posted by WuWujo View Post
    '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".

    Quote Originally Posted by WuWujo View Post
    '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.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2013
    Posts
    4
    Thanks. It's working

Similar Threads

  1. pixelformat??
    By Gabri in forum OpenGL: User Software
    Replies: 1
    Last Post: 04-08-2005, 01:10 PM
  2. Pixelformat enumeration
    By arithon in forum OpenGL: Windows
    Replies: 5
    Last Post: 06-05-2004, 10:16 AM
  3. PixelFormat-Problems
    By pgmeiner in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 07-23-2002, 02:57 AM
  4. PixelFormat with layer? or not?
    By imported_SEB in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-18-2001, 04:39 AM
  5. wglMakeCurrent + PIXELFORMAT
    By drakaza in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-22-2000, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean