예제 #1
0
        public override void glDraw()
        {
            freash_count++;
            BitmapData     bmpData;
            ImageConverter converter = new ImageConverter();

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
            OpenGL.glLoadIdentity();
            GL.glBindTexture(GL.GL_TEXTURE_2D, texID[0]);
            GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
            GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
            GL.glEnable(GL.GL_TEXTURE_2D);

            GL.glColor3f(1.0f, 1.0f, 1.0f);
            switch (Viewer.nDataFrameNum)
            {
            case 0:
                Viewer.bmp0.RotateFlip(RotateFlipType.RotateNoneFlipY);
                bmpData = Viewer.bmp0.LockBits(new Rectangle(0, 0, Viewer.bmp0.Width, Viewer.bmp0.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_LUMINANCE, Viewer.bmp0.Width, Viewer.bmp0.Height, 0, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE, bmpData.Scan0);
                //Viewer.input = new byte[bmpData.Stride * bmpData.Height];
                //Marshal.Copy(bmpData.Scan0, Viewer.input, 0, bmpData.Stride * bmpData.Height);
                Viewer.bmp0.UnlockBits(bmpData);
                break;

            case 1:
                Viewer.bmp1.RotateFlip(RotateFlipType.RotateNoneFlipY);
                bmpData = Viewer.bmp1.LockBits(new Rectangle(0, 0, Viewer.bmp1.Width, Viewer.bmp1.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_LUMINANCE, Viewer.bmp1.Width, Viewer.bmp1.Height, 0, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE, bmpData.Scan0);
                //Viewer.input = new byte[bmpData.Stride * bmpData.Height];
                //Marshal.Copy(bmpData.Scan0, Viewer.input, 0, bmpData.Stride * bmpData.Height);
                Viewer.bmp1.UnlockBits(bmpData);
                break;

            case 2:
                Viewer.bmp2.RotateFlip(RotateFlipType.RotateNoneFlipY);
                bmpData = Viewer.bmp2.LockBits(new Rectangle(0, 0, Viewer.bmp2.Width, Viewer.bmp2.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_LUMINANCE, Viewer.bmp2.Width, Viewer.bmp2.Height, 0, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE, bmpData.Scan0);
                //Viewer.input = new byte[bmpData.Stride * bmpData.Height];
                //Marshal.Copy(bmpData.Scan0, Viewer.input, 0, bmpData.Stride * bmpData.Height);
                Viewer.bmp2.UnlockBits(bmpData);
                break;

            case 9:
                bmpData = Viewer.bmp_backup.LockBits(new Rectangle(0, 0, Viewer.bmp_backup.Width, Viewer.bmp_backup.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, (int)GL.GL_LUMINANCE, Viewer.bmp_backup.Width, Viewer.bmp_backup.Height, 0, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE, bmpData.Scan0);
                //Viewer.input = new byte[bmpData.Stride * bmpData.Height];
                //Marshal.Copy(bmpData.Scan0, Viewer.input, 0, bmpData.Stride * bmpData.Height);
                Viewer.bmp_backup.UnlockBits(bmpData);
                break;

            default:
                break;
            }
            Viewer.Save_current_tobackup();
            //TN();
            Drawsquare(Viewer.rotate_degree);
            GL.glDisable(GL.GL_TEXTURE_2D);
            if (Viewer.Cursor)
            {
                double x_ratio  = ((double)Viewer.Mouse.X / Viewer.bmp0.Width) * 2 - 1;
                double y_ratio  = (1 - ((double)Viewer.Mouse.Y / Viewer.bmp0.Height)) * 2 - 1;
                double x_cursor = (x_ratio - Viewer.Display_Range_L) / (2 * Viewer.ZoomIn_Ratio);
                double y_cursor = (y_ratio - Viewer.Display_Range_D) / (2 * Viewer.ZoomIn_Ratio);
                GL.glColor3f(1.0f, 0.0f, 0.0f);
                GL.glBegin(GL.GL_LINES);
                GL.glVertex2d(x_cursor * 2 - 1, -1);
                GL.glVertex2d(x_cursor * 2 - 1, 1);
                GL.glEnd();
                GL.glBegin(GL.GL_LINES);
                GL.glVertex2d(-1, y_cursor * 2 - 1);
                GL.glVertex2d(1, y_cursor * 2 - 1);
                GL.glEnd();
            }
            if (Viewer.ROI)
            {
                DrawROIRange();
            }

            if (Viewer.FPS_Enable)
            {
                this.glPrint(0, this.Size.Height - 20, "FPS :" + Viewer.FPS.ToString("f4"));
            }
            GC.Collect();
            GL.glFlush();
            GL.glFinish();
        }