Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand you correctly then this should be close to what you after, using glReadPixels and glDrawPixels.</p> <p><a href="http://img392.imageshack.us/img392/8540/zoomla1.jpg" rel="nofollow noreferrer"></a></p> <p>Sorry it's C++ not C# but the OpenGL function should still be the same.</p> <pre><code>// main.cpp // glut Text #ifdef __WIN32__ #define WIN32_LEAN_AND_MEAN #include &lt;windows.h&gt; #endif #include &lt;GL/glut.h&gt; #include &lt;cstdio&gt; int WIDTH = 800; int HEIGHT = 600; int MouseButton, MouseY = 0, MouseX = 0; const int size = 80; char *image, rect[size*size*3]; int imagewidth, imageheight; bool Init() { int offset; FILE* file = fopen("image.bmp", "rb"); if (file == NULL) return false; fseek(file, 10, SEEK_SET); fread(&amp;offset, sizeof(int), 1, file); fseek(file, 18, SEEK_SET); fread(&amp;imagewidth, sizeof(int), 1, file); fread(&amp;imageheight, sizeof(int), 1, file); fseek(file, offset, SEEK_SET); image = new char[imagewidth*imageheight*3]; if (image == NULL) return false; fread(image, 1, imagewidth*imageheight*3, file); fclose(file); return true; } void Reshape(int width, int height) { WIDTH = width; HEIGHT = height; glViewport(0 , 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, width, 0, height); } void Display() { int size2 = size/2; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRasterPos2i(0,0); glPixelZoom(1.f, 1.f); glDrawPixels(imagewidth, imageheight, 0x80E0/*GL_RGB*/, GL_UNSIGNED_BYTE, image); glReadPixels(MouseX-size2, MouseY-size2, size, size, GL_RGB, GL_UNSIGNED_BYTE, rect); glPixelZoom(2.f, 2.f); glRasterPos2i(MouseX-size, MouseY-size); glDrawPixels(size, size, GL_RGB, GL_UNSIGNED_BYTE, rect); glFlush(); glutSwapBuffers(); } void Mouse(int button, int state, int x, int y) { if (state == GLUT_DOWN) MouseButton &amp;= (1&lt;&lt;button); else MouseButton &amp;= ~(1&lt;&lt;button); } void MouseMove(int x, int y) { MouseX = x; MouseY = HEIGHT - y; } int main(int argc, char* argv[]) { glutInit(&amp;argc, argv); if (Init() == false) return 1; glutInitWindowSize(WIDTH, HEIGHT); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutCreateWindow("glut_Text"); glClearColor(0.25, 0.25, 0.25, 1.0); glutReshapeFunc(Reshape); glutDisplayFunc(Display); glutIdleFunc(Display); glutMouseFunc(Mouse); glutMotionFunc(MouseMove); glutPassiveMotionFunc(MouseMove); glutMainLoop(); return 0; } </code></pre> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload