import sys, math, time from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * import Image img = Image.open('image.jpg').transpose(Image.FLIP_TOP_BOTTOM).convert('RGB') def draw(): glClearColor(1,1,0,0) glClear(GL_COLOR_BUFFER_BIT) glPixelStoref(GL_UNPACK_ALIGNMENT, 1) glRasterPos2f(0.0, -1.1) glDrawPixels(img.size[0], img.size[1], GL_RGB, GL_UNSIGNED_BYTE, img.tostring()) glutSwapBuffers() def keyboard(key, x, y): if key == chr(27): sys.exit(0) def idle(): glutPostRedisplay() glutInit([]) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(500, 500) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutIdleFunc(idle) glutMainLoop()