Stretching images?

337 views
Skip to first unread message

Grzegorz Adam Hankiewicz

unread,
Aug 17, 2008, 10:06:18 AM8/17/08
to Pyglet mailing list
Hello.

I'm new to pyglet and to learn how it works I'm rewritting an old
image viewer I wrote with another graphic library.

So far I have the window drawing and keyboard detection to go from
image to image. However, I'm not seeing anywhere a stretch method or
something like that which I could use to make the image fit into the
window.

In my previous program I would load the image with PIL, rescale it and
then blit it. But how could I do this with OpenGL so that I can leave
the scaling to the video card/accelerator?

I saw something about projections in the contrib directory but didn't
understand too much of it. Is that the way to go?

Alex Holkner

unread,
Aug 17, 2008, 7:09:41 PM8/17/08
to pyglet...@googlegroups.com
On 8/18/08, Grzegorz Adam Hankiewicz <gra...@titanium.sabren.com> wrote:
>
> Hello.
>
> I'm new to pyglet and to learn how it works I'm rewritting an old
> image viewer I wrote with another graphic library.
>
> So far I have the window drawing and keyboard detection to go from
> image to image. However, I'm not seeing anywhere a stretch method or
> something like that which I could use to make the image fit into the
> window.

If you're using blit(), you can pass in width and height keyword parameters:

http://pyglet.org/doc/api/pyglet.image.Texture-class.html#blit

If you're using sprites, use the scale property:

http://pyglet.org/doc/api/pyglet.sprite.Sprite-class.html#scale

Alex.

Grzegorz Adam Hankiewicz

unread,
Oct 11, 2008, 3:53:27 PM10/11/08
to pyglet...@googlegroups.com
El 18/08/2008, a las 1:09, Alex Holkner escribió:
> On 8/18/08, Grzegorz Adam Hankiewicz <gra...@titanium.sabren.com>
> wrote:
>> [...] However, I'm not seeing anywhere a stretch method or

>> something like that which I could use to make the image fit into the
>> window.
>
> If you're using blit(), you can pass in width and height keyword
> parameters:
>
> http://pyglet.org/doc/api/pyglet.image.Texture-class.html#blit
>
> If you're using sprites, use the scale property:
>
> http://pyglet.org/doc/api/pyglet.sprite.Sprite-class.html#scale

I'm still trying to figure out how to find information in those mazes
of little one liners each appended to individual methods overriden by
deep classes' hierarchies.

In hope of improving the situation a bit, please accept the attached
example to help future users.

stretch_example.diff

Grzegorz Adam Hankiewicz

unread,
Nov 1, 2008, 6:55:15 AM11/1/08
to pyglet...@googlegroups.com

Alex Holkner

unread,
Nov 1, 2008, 8:28:03 AM11/1/08
to pyglet...@googlegroups.com
On 10/12/08, Grzegorz Adam Hankiewicz <gra...@titanium.sabren.com> wrote:
> While I'm at it, if I put a print statement inside the window's
> on_draw() method, I notice it gets called even when the user moves the
> mouse over the window (I'm running under macosx).

This has been commented on several times on this list; check the
archives. In short: this behaviour is by design: pyglet iterates the
event loop after any event, whether or not it's handled, which by
default causes a redraw. You can use the Window.invalid flag to take
control of when redraws are made. The default situation will be
improved in pyglet 1.2.

Alex.

Grzegorz Adam Hankiewicz

unread,
Nov 1, 2008, 8:57:56 AM11/1/08
to pyglet...@googlegroups.com

El 01/11/2008, a las 13:28, Alex Holkner escribió:
> This has been commented on several times on this list; check the
> archives [...]

Sorry for being so bad at explaining. I was more interested in your
answer on providing examples for other people and to use these as
documentation helpers. If you are not, I won't bother to try and write
any more.

Reply all
Reply to author
Forward
0 new messages