I gave up, and used PIL instead of it.

mgr = pyglet.image.get_buffer_manager()
color_buffer = mgr.get_color_buffer()
image = color_buffer.image_data.get_image_data()
pil_image = Image.fromstring(image.format, (image.width,
image.height), image.get_data(image.format, image.pitch))
pil_image = pil_image.transpose(Image.FLIP_TOP_BOTTOM)
pil_image = pil_image.convert('RGB')
pil_image.save(file, "PNG")


On Mar 3, 6:41 pm, Philippe <[email protected]> wrote:
> tried this also, but not better:
>
> rawimage = cb.image_data.get_image_data()
> pixels = rawimage.get_data(format, pitch)
> for i, v in enumerate(pixels):
>     if (i+1) % 4:
>         pixels_RGB.append(v)
> cb.image_data.set_data('RGB', rawimage.width * len('RGB'), pixels_RGB)
>
> start to not have new ideas :/
>
> On Mar 3, 6:14 pm, Philippe <[email protected]> wrote:
>
> > actually, if I do
> > cb.image_data.format = 'RGB'
> > and then
> > print cb.image_data.format
>
> > I get: 'RGBA' :/
>
> > On Mar 3, 5:57 pm, Philippe <[email protected]> wrote:
>
> > > thank you !
> > > In my case, I need to convert to RGB.
>
> > > I went into pyglet.image.codecs.pil
> > > and there, I forced format = 'RGB' in PILImageEncoder.encode()
> > > the result was good.
> > > but the way to do it, not really clean...
>
> > > then, I tried to do that:
> > > mgr = pyglet.image.get_buffer_manager()
> > > encoder = pyglet.image.codecs.pil.PILImageEncoder()
> > > cb = mgr.get_color_buffer()
> > > cb.image_data.format = 'RGB'
> > > cb.save(file, encoder=encoder)
>
> > > but the result was like before. a "double alpha"
>
> > > On Mar 3, 5:24 pm, Tristam MacDonald <[email protected]> wrote:
>
> > > > On Wed, Mar 3, 2010 at 11:07 AM, Philippe <[email protected]> 
> > > > wrote:
> > > > > can you tell a bit more about the "blending equations" ?
> > > > > I have no idea where to look for that and how I can use it to solve
> > > > > my problem.
>
> > > > I think you had better explain exactly what you are trying to achieve,
> > > > because the problem isn't entirely trivial to solve.
>
> > > > For repeated blending to work correctly, the alpha values of incoming
> > > > fragments have to be combined with the alpha values already in the
> > > > framebuffer:
> > > > - In your case, I believe that you start by rendering an opaque 
> > > > background,
> > > > which will fill the backbuffer with alpha values of 1.0
> > > > - Then you render a sprite with 50% transparency (i.e. alpha = 0.5) 
> > > > over the
> > > > opaque background.
> > > > - This will result in the alpha values being multiplied, and 1.0 * 0.5 =
> > > > 0.5, so the resulting value in the backbuffer will be 0.5, and your
> > > > screenshots will come out partially transparent wherever you rendered a
> > > > sprite.
>
> > > > If you don't want your resulting screenshot to have transparent areas, 
> > > > just
> > > > don't save the alpha channel (i.e. convert to RGB). Note that this won't
> > > > affect the rendered transparency in any way, because the colours have
> > > > already been blended in the framebuffer.
>
> > > > If you do want the image to retain proper transparency, then disable
> > > > blending, render the background with alpha=0.0, and re-enable blending
> > > > before rendering sprites.
>
> > > > --
> > > > Tristam MacDonaldhttp://swiftcoder.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to