Problem with saving image from wx.GLCanvas

Hi,

when I try to save an image rendered on glcanvas using glReadPixels,
the statusbar, toolbars and menubar are included in the image. I tried
it with the glcanvas demo and I have the same problem.

view = glGetIntegerv(GL_VIEWPORT)
img = wx.EmptyImage(view[2], view[3] )
pixels = glReadPixels(0, 0, view[2], view[3], GL_RGB,
     GL_UNSIGNED_BYTE)
img.SetData( pixels )
img = img.Mirror(False)
img.SaveFile("out.png", wx.BITMAP_TYPE_PNG)

The final image size is ok but the image itself is shrunk in vertical
direction. See attachment.

Please, could someone tell me what am I doing wrong?

Anna

obr.png

Just a guess as I don't use glcanvas.

But looking at the doc of glReadPixels and glGetIntegerv I think you should use:

pixels = glReadPixels(view[0], view[1], view[2], view[3], GL_RGB,
     GL_UNSIGNED_BYTE)

Werner

···

On 10/15/2011 04:43 PM, Anna Kratochv�lov� wrote:

Hi,

when I try to save an image rendered on glcanvas using glReadPixels,
the statusbar, toolbars and menubar are included in the image. I tried
it with the glcanvas demo and I have the same problem.

view = glGetIntegerv(GL_VIEWPORT)
img = wx.EmptyImage(view[2], view[3] )
pixels = glReadPixels(0, 0, view[2], view[3], GL_RGB,
     GL_UNSIGNED_BYTE)
img.SetData( pixels )
img = img.Mirror(False)
img.SaveFile("out.png", wx.BITMAP_TYPE_PNG)

The final image size is ok but the image itself is shrunk in vertical
direction. See attachment.

Please, could someone tell me what am I doing wrong?

Hi,

when I try to save an image rendered on glcanvas using glReadPixels,
the statusbar, toolbars and menubar are included in the image. I tried
it with the glcanvas demo and I have the same problem.

view = glGetIntegerv(GL_VIEWPORT)
img = wx.EmptyImage(view[2], view[3] )
pixels = glReadPixels(0, 0, view[2], view[3], GL_RGB,
GL_UNSIGNED_BYTE)
img.SetData( pixels )
img = img.Mirror(False)
img.SaveFile("out.png", wx.BITMAP_TYPE_PNG)

The final image size is ok but the image itself is shrunk in vertical
direction. See attachment.

Please, could someone tell me what am I doing wrong?

Just a guess as I don't use glcanvas.

But looking at the doc of glReadPixels and glGetIntegerv I think you should
use:

pixels = glReadPixels(view[0], view[1], view[2], view[3], GL_RGB,
GL_UNSIGNED_BYTE)

Werner

Maybe I should but this is not the problem because view[0] = view[1] = 0

Anna

···

On Sat, Oct 15, 2011 at 5:01 PM, werner <wbruhin@free.fr> wrote:

On 10/15/2011 04:43 PM, Anna Kratochvílová wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en