Sorry if you're receiving this a second time. I had trouble with the
initial send.
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
second issue.
(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
relevant:
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,
Tim.
<begin code>
import numpy, glumpy
import Image
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.
@fig.event
def on_draw():
print 'Drawing requested'
fig.clear()
image.update()
image.draw(image.x,image.y,0.,width=fig.width/4.,height=fig.height/
4.)
grefimg.update()
grefimg.draw(grefimg.x,grefimg.y,
0.,width=fig.width,height=fig.height)
@fig.event
def on_mouse_motion(x, y, dx, dy):
print 'Mouse motion (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f)' % (x,y,dx,dy)
@fig.event
def on_mouse_drag(x, y, dx, dy, button):
print 'Mouse drag (x=%.1f, y=%.1f, dx=%.1f, dy=%.1f, button=%d)' %
(x,y,dx,dy,button)
image.x = x + dx
image.y = y + dy
fig.redraw()
fig.show()
<end code>
On Feb 29, 12:31 pm, Nicolas Rougier <
nicolas.roug...@gmail.com>
wrote: