Sorry if you're receiving this a second time. I had trouble with the
Thank you very much for your quick reply. I've tried to add alpha
channels to by images, but I still have two problems.
(1) Transparency still doesn't seem to work. The addition of the
alpha channel does seem to make the image less "intense" but it does
not allow the image underneath to be seen through it. I've written a
simple piece of code (included below) which demonstrates this and the
(2) Addition of the alpha channels slows the movement of the image
(when dragged with the mouse) immensely. Prior to addition of the
alpha channel everything is extremely fast and responsive. I looked
through some of the OpenGL docs and found something which might be
QUOTED FROM: http://www.opengl.org/wiki/Common_Mistakes#No_Alpha_in_the_Framebuffer
"No Alpha in the Framebuffer
Be sure you create a double buffered context and make sure you ask for
a alpha component. With GLUT, you can call
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH
| GLUT_STENCIL) in which GL_ALPHA asks for a alpha component."
I'm likely just doing something stupid as I'm fairly new to image
manipulation. Thanks for any suggestions you might have,
import numpy, glumpy
import numpy as np
refimg = np.random.rand(512,512)
img = np.random.rand(100,100)
refimg = numpy.asarray(refimg,numpy.float32)
refimg = numpy.asarray([refimg,numpy.ones_like(refimg)]).T
img = numpy.asarray(img,numpy.float32)
img = numpy.asarray([img,0.1*numpy.ones_like(img)]).T
fig = glumpy.figure( (512,512) )
grefimg = glumpy.image.Image(refimg, format='LA')
image = glumpy.image.Image(img, format='LA')
image.x = 0.
image.y = 0.
grefimg.x = 0.
grefimg.y = 0.
print 'Drawing requested'
def on_mouse_motion(x, y, dx, dy):
print 'Mouse motion (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f)' % (x,y,dx,dy)
def on_mouse_drag(x, y, dx, dy, button):
print 'Mouse drag (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f, button=%d)' %
image.x = x + dx
image.y = y + dy
On Feb 29, 12:31 pm, Nicolas Rougier <nicolas.roug...@gmail.com