Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Array image redering aliasing???

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2014
    Posts
    12

    Array image redering aliasing???

    Hi, I'm trying to render a array image on a cube,
    Here is the result and the real image that i would like to render it.
    Click image for larger version. 

Name:	aliasing.jpg 
Views:	102 
Size:	18.2 KB 
ID:	1458Click image for larger version. 

Name:	aliasing2.jpg 
Views:	101 
Size:	10.3 KB 
ID:	1459

    For example, i have a black and white array image, what is the problem makes my image like this??

    Anyone could help me?
    Thanks

    Code :
    double[] slice = new double[]
    {
    0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,
    0,0,1,1,1,0,0,
    0,0,1,1,1,0,0,
    0,0,1,1,1,0,0,
    0,0,0,0,0,0,0,
    0,0,0,0,0,0,0
    }
     
    gl.Enable(OpenGL.GL_TEXTURE_2D);
    gl.ShadeModel(OpenGL.GL_SMOOTH);
    gl.Enable(OpenGL.GL_DEPTH_TEST);
    gl.DepthFunc(OpenGL.GL_LEQUAL);
    gl.Hint(OpenGL.GL_PERSPECTIVE_CORRECTION_HINT, OpenGL.GL_NICEST);
     
    uint[] texture = new uint[1];
    gl.GenTextures(1, texture);
    gl.BindTexture(OpenGL.GL_TEXTURE_2D, texture[0]);
     
     
    Bitmap texslice = new Bitmap(7, 7 ,PixelFormat.Format24bppRgb);
     
    // Create the converter to create a Bitmap from the array
    ArrayToImage conv = new ArrayToImage(7, 7);
     
    // Declare an image and store the pixels on it
    conv.Convert(slice, out texslice);
     
     gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, 1, texslice.Height, texslice.Width, 0, OpenGL.GL_LUMINANCE, OpenGL.GL_UNSIGNED_BYTE, 
         texslice.LockBits(new Rectangle(0, 0, texslice.Width, texslice.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb).Scan0);
     
     
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR);	// Linear Filtering 
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR);	// Linear Filtering 
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE); 
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE);

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,470
    Quote Originally Posted by Shintai View Post
    Code :
     gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, 1, texslice.Height, texslice.Width, 0, OpenGL.GL_LUMINANCE, OpenGL.GL_UNSIGNED_BYTE, 
         texslice.LockBits(new Rectangle(0, 0, texslice.Width, texslice.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb).Scan0);
    I have no idea what texslice.LockBits() does (not being part of OpenGL), but PixelFormat.Format24bppRgb looks suspicious. Are you passing 3-component (RGB, 24-bpp) data where 1-component (luminance, 8-bpp) data is expected? That would produce artefacts similar to the ones you're getting.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2014
    Posts
    12
    Thanks for you suggestion!
    It's worked before i changed it to PixelFormat.Format8bppIndexed!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •