Simon Oberhammer | 1 Feb 14:05 2007
Picon

Re: sdl_ttf font render failed

Thanks, Marius.. didn't find that.
greetings
 simon

On 1/31/07, Marius Gedminas <mgedmin@...> wrote:
> On Wed, Jan 31, 2007 at 03:42:37PM +0100, Simon Oberhammer wrote:
> > hi pygamers,
> > whenever I use font.render() with the antialias param set to False I
> > get this error:
> >
> >  File "pysssi_dist.py", line 258, in printf
> >    s = self.print_font.render( str,False,self.color1)
> > pygame.error: SDL_ttf render failed
>
> Actually, you only get this if you call font.render with a string that
> contains a space character, and with antialias set to False.
>
> Seems to be a known bug in the SDL_ttf version that is in Ubuntu.
>
> Marius Gedminas
> --
> Always proofread carefully to see if you any words out.
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iD8DBQFFwPh2kVdEXeem148RAgO3AJkB/MfPg7rqfdxSkc4YVKVXwr+jbQCgioGn
> HRHIzv51ZD5Zlb7MiCQkw8Y=
> =iETx
(Continue reading)

Kamilche | 1 Feb 17:52 2007

Perspective Transform Quad

I have a need to tile a bitmap across an arbitrary quadrilateral, and
apply perspective to it.
The Python Imaging Library (PIL) has an undocumented function that
might work, but I can't figure out how to make it work. You're
supposed to pass it 8 parameters, a b c d e f g h .

What I want is to take a rectangular texture map and 'flop it down on
the floor' - pinch in the left and right with perspective, and squash
down the top with perspective. I've modified those 8 parameters and
examined the results, but that hasn't brought me any closer to my
goal.

The PIL function is this:

im2 = im.transform(im.size, Image.PERSPECTIVE, (1, 0, 0, 0, 1, -100,
0, .001), Image.BILINEAR)

Here's hoping someone can shed some light on this function!

David Gowers | 1 Feb 22:37 2007
Picon

Re: Perspective Transform Quad



On 2/2/07, Kamilche <kamilche-pTaok6l78gRWk0Htik3J/w@public.gmane.org> wrote:
I have a need to tile a bitmap across an arbitrary quadrilateral, and
apply perspective to it.
The Python Imaging Library (PIL) has an undocumented function that
might work, but I can't figure out how to make it work. You're
supposed to pass it 8 parameters, a b c d e f g h .

What I want is to take a rectangular texture map and 'flop it down on
the floor' - pinch in the left and right with perspective, and squash
down the top with perspective. I've modified those 8 parameters and
examined the results, but that hasn't brought me any closer to my
goal.

The PIL function is this:

im2 = im.transform(im.size, Image.PERSPECTIVE, (1, 0, 0, 0, 1, -100,
0, .001), Image.BILINEAR)

Here's hoping someone can shed some light on this function!

The  eight parameters might match the nine-element tranformation matrix shown by the Perspective tool in GIMP, with one element being treated as having a constant value.
You could certainly try and see if you get any meaningful results using GIMP's matrices.


Alex Holkner | 2 Feb 00:42 2007
Picon
Picon

Re: Perspective Transform Quad

Kamilche wrote:

> I have a need to tile a bitmap across an arbitrary quadrilateral, and
> apply perspective to it.
> The Python Imaging Library (PIL) has an undocumented function that
> might work, but I can't figure out how to make it work. You're
> supposed to pass it 8 parameters, a b c d e f g h .

My version of PIL doesn't have this function (the Image.PERSPECTIVE 
constant exists, but it raises an exception), but most likely the 8 
parameters correspond to all but one of the elements for a 2D 
transformation matrix:

[x']   [a b c][x]
[y'] = [d e f][y]
[w']   [g h 1][1]

The AFFINE transform method allows you to supply 6 of these:

[x'] = [a b c][x]
[y'] = [d e f][y]
[w'] = [0 0 1][1]

Typically projection occurs from 3D to 2D, and the Z coordinate is used 
as the perspective divide:

[x'] = [1 0 0 0][x]
[y'] = [0 1 0 0][y]
[z'] = [0 0 1 0][z]
[w'] = [0 0 1 0][1]

The resulting 4-tuple (x,y,z,w) is divided through by w to project into 
3D: (x/w, y/w, z/w).

In your application you don't have 3D data, but you can achieve the same 
result using Y as the perspective divide (higher values of Y mean higher 
values of W, so pixels near the top of the image will be have have their 
X coordinate divided more):

[x'] = [1 0 0][x]
[y'] = [0 y 0][y]
[w'] = [0 1 0][1]

However, it appears that the function you describe will not accept "y" 
as a matrix parameter, or any value besides 0 for the bottom-left 
element.  So this function won't solve your problem.

There is a QUAD transform in PIL which you could use to map a trapezium 
to a rectangle.  The result will not look correct though, as it will not 
apply perspective-correct interpolation.  The result may be "good 
enough" (the current generation of mobile devices with 3D chipsets do 
not employ perspective correction, but all PC chips have done so since 
texture mapping was introduced).

Any 3D imaging library will be able to apply the perspective you need.

Cheers
Alex.

Kamilche | 2 Feb 02:34 2007

Re: Perspective Transform Quad

Well, thanks for the info. I thought as much. I think I'll give it a 
miss - I don't need it badly enough to require OpenGL to be included as 
well.

--Kamilche

Charles Christie | 2 Feb 14:15 2007
Picon

Re: Newbie needs help, what's the most efficient (or easiest) way to do this?

Crap. My hard drive died. Good thing I backed this thing up, huh? Well, now that I've recovered, I will post the code as an attatchment like I said I would. Here you go.

On 1/31/07, Charles Joseph Christie II <sonicbhoc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
I figured I was doing something wrong... I didn't know I could include
attachments. Sorry, this is really the first experience I've had with
a mailing list...

A few e-mails up, I said I was trying to get the game to display the
letters and words you typed correctly in a row. Someone said to put the
sprites in their own group, so I thought he meant class. So that's what
I did. Yet, the text still doesn't show up on screen... What am I doing
wrong?

Yeah. So when I get back to my laptop I'll attach the code instead of
sending it in the body of my message next time. Sorry about that.

On Tue, 30 Jan 2007 16:26:30 -0600
Luke Paireepinart < rabidpoobear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Charles Christie wrote:
> > Aww.... it still doesn't work... am I doin' it right?
> What doesn't work?
> it's easier to give you help if you explain the problem you're having
> and only include
> code snippets you think are relevant...
> I have zero desire to read through all your code and try to figure
> out what the problem is,
> especially since if you think there is a problem you probably know
> approximately where it is occurring...
> :)
> Also attachments are better than including the whole thing in your
> e-mail because then you can be
> sure that it isn't messing up your tabs, and you won't have problems
> with wrapping
> -Luke

Attachment (helpers.py): application/octet-stream, 1292 bytes
Attachment (typinggame.py): application/octet-stream, 5195 bytes
altern | 4 Feb 11:27 2007
Picon

os.environ on macintosh

hi all

Yesterday I tested on a mac some code I have been developing on linux 
and windows. There was a problem with the drawing surface being 
displaced from the window where it was contained. I found that this was 
causing the problem:
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)

Setting x,y to 0,0 correctly shown the drawing area fitting the window, 
setting it to 10,20 would move the drawing area 10 pixels right and 20 
pixels up (!) from the bottom, and so on.

However the actual position of the window in the screen was not affected 
by this command unlike windows and linux.

I guess this is something to do with the way mac interprets those 
environmental variables. I would like to find a way to archive on mac 
the same effect I get on win/linux (position the SDL window within the 
desktop), any ideas?

thanks!

enrike

Adam Fitch | 4 Feb 12:48 2007
Picon

Newbie needs Pygame instalation help (sorry)!

Hello,

So, I'm very new to scripting languages and the like, and not *that* good with computers, so sorry if this is stuff that should be plain and simple to me. :-)  I'm going to go step-by-step and explain what I've done, and hopefully someone can tell me where I'm going wrong.  Also, some basic info: I'm running Windows XP Professional.

First, I downloaded and installed Python itself, version 2.4.4 (the "python-2.4.4.msi" file), from python.org.

Second, I downloaded and ran the "pygame-1.7.1release.win32-py2.4.exe " file.

Third, I downloaded the "pygame-1.7.1release.zip" file.  However, I'm not sure where to extract this file to, and it looks like the "art assets" I need are there in the "pygame-1.7.1release\examples\data\ " directory.

So anyway, from the tutorial (Lecture 3 at http://rene.f0o.com/mywiki/LectureThree), I typed the following into the Python command line:

>>> import pygame, sys,os
>>> from pygame.locals import *
>>> pygame.init()
(6, 0)
>>> window = pygame.display.set_mode((468, 60))
>>> pygame.display.set_caption ('Monkey Fever')
>>> screen = pygame.display.get_surface()
>>> monkey_head_file_name = os.path.join("data","chimp.bmp")
>>> print monkey_head_file_name
data\chimp.bmp
>>> monkey_surface = pygame.image.load(monkey_head_file_name)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
pygame.error: Couldn't open data\chimp.bmp
>>> screen.blit(monkey_surface, (0,0))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'monkey_surface' is not defined

Now, obviously, I know why this failed; 'monkey_surface' is not defined, because it failed to define itself in the "monkey_surface = pygame.image.load(monkey_head_file_name)" line.  Pygame couldn't open the "chimp.bmp" file.  The question is, where *should* this file be located, and why isn't it in the "C:\\Program Files\Pygame-Docs\examples\" directory, as it says it should be in the tutorial?  Pygame isn't creating a directory called "C:\\Program Files\Pygame-Docs\examples\", and it looks like the stuff I need is in the " pygame-1.7.1release.zip" file; it seems like all I need to do is figure out where to put that data so that Pygame will recognize it.
 
As a side note, the Pygame window doesn't seem to be initializing correctly; it just stays black, and when I mouseover it, I get the "hourglass" icon from Windows.

Anyway, thanks for any help anyone can provide, and, again, I'm sorry to be asking such simple questions, but I've tried for a week to work out what's gone wrong myself, and it seems better to ask the professionals at this point. :-)

Thanks,

-Adam
Luke Paireepinart | 4 Feb 14:34 2007
Picon

Re: Newbie needs Pygame instalation help (sorry)!

Adam Fitch wrote:
> Hello,
Hi!
> First, I downloaded and installed Python itself, version 2.4.4 (the 
> "python-2.4.4.msi" file), from python.org <http://python.org>.
Good so far.
>
> Second, I downloaded and ran the "pygame-1.7.1release.win32-py2.4.exe 
> " file.
Yep, that's what you should do.
>
> Third, I downloaded the "pygame-1.7.1release.zip" file.  However, I'm 
> not sure where to extract this file to, and it looks like the 
> "art assets" I need are there in the 
> "pygame-1.7.1release\examples\data\ " directory.
Yes.  Basically what you're probably interested in are the \examples and 
the \docs directories. the rest of the stuff in that zip is just source, 
which you don't need because you installed pygame already.
>
> So anyway, from the tutorial (Lecture 3 at 
> http://rene.f0o.com/mywiki/LectureThree), I typed the following into 
> the Python command line:
>
> >>> import pygame, sys,os
> >>> from pygame.locals import *
> >>> pygame.init()
> (6, 0)
> >>> window = pygame.display.set_mode((468, 60))
> >>> pygame.display.set_caption ('Monkey Fever')
> >>> screen = pygame.display.get_surface()
> >>> monkey_head_file_name = os.path.join("data","chimp.bmp")
> >>> print monkey_head_file_name
> data\chimp.bmp
> >>> monkey_surface = pygame.image.load(monkey_head_file_name)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> pygame.error: Couldn't open data\chimp.bmp
> >>> screen.blit(monkey_surface, (0,0))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'monkey_surface' is not defined
>
> Now, obviously, I know why this failed; 'monkey_surface' is not 
> defined, because it failed to define itself in the "monkey_surface = 
> pygame.image.load(monkey_head_file_name)" line.  Pygame couldn't open 
> the "chimp.bmp" file.  The question is, where *should* this file be 
> located, and why isn't it in the "C:\\Program 
> Files\Pygame-Docs\examples\" directory, as it says it should be in the 
> tutorial?  Pygame isn't creating a directory called "C:\\Program 
> Files\Pygame-Docs\examples\", and it looks like the stuff I need is in 
> the " pygame-1.7.1release.zip" file; it seems like all I need to do 
> is figure out where to put that data so that Pygame will recognize it.
Python searches a certain number of directories when it is looking for 
files. generally, it searches the current working directory first.
So one way you could solve this is from running your python program from 
a certain directory.
for example, i create the directory 'c:\pygame\data\' with the file 
'test.bmp' in it (which is a jpg... just kidding)
Then I start a cmd window by going to start > run, typing cmd, and 
hitting enter.
i issue the command 'cd c:\pygame'
Then I type 'python', which runs the interactive interpreter.
(If this doesn't work, type 'path = %path%;c:\python24' and try the 
command again.
this sets your path to be the same as it was before (%path%) with the 
addition of your python directory.)
now we can check our current directory:
 >>> print os.getcwd()
C:\pygame

you should be able to do everything from here.
 >>> pygame.image.load('data\\test.bmp')
<Surface(160x120x24 SW)>

There are other ways to do this, but this is the way i would do it.
If you included the data somewhere else on the pypath, then someday you 
might be trying to load 'test.bmp' and not realize you named it 
'tset.bmp' on accident and it now is loading some image you don't want 
it to.
>  
> As a side note, the Pygame window doesn't seem to be initializing 
> correctly; it just stays black, and when I mouseover it, I get the 
> "hourglass" icon from Windows.
Pygame needs calls to its display.update() method as well as clearing 
out the input queue to keep this from happening.  You'll get to that 
later in the tutorial.
Try running examples\chimp.py if you want to make sure pygame is working.
> Anyway, thanks for any help anyone can provide, and, again, I'm sorry 
> to be asking such simple questions, but I've tried for a week to work 
> out what's gone wrong myself, and it seems better to ask the 
> professionals at this point. :-)
I think you made the right choice :)

By the way, if you are just getting into Python, you might want to look 
into joining the tutor mailing list also.
There are lots of friendly and knowledgeable people who hang out on that 
list.
Hope to see you there, and be sure to update us on your progress.
You'll probably get some other e-mails detailing other ways to do this 
as well.
>
> Thanks,
>
> -Adam
You're welcome.
-Luke

Charles Christie | 4 Feb 23:49 2007
Picon

Re: Newbie needs help, what's the most efficient (or easiest) way to do this?

Ha~! I got it working! I went over my code and compared it to a pygame example, and noticed I didn't add my new classes to the "all.add(textsprite)" at the bottom! Well, now it works, but it places the text in the wrong place. I know how to fix that, though! I will have to change parts of the code to be owned by the textsprite class so that the scoring class can access it later, though. Things are definitely shaping up! If my commenting on my progress is getting annoying or if I should only ask for help and not send messages like this, then just say so. I'm still VERY new to this mailing list thing and I'm really excited and loaded up with sugar right now, so forgive my overenthusiasm.

I'm going to go and ask the guy that's helping me with sound how far he's gotten later. If you see anything wrong with the code, or see any places I can improve, can you just say something? I want to get as good at this as I can and I'm willing to invest as much time as I need to in order to make this something memorable and net me that A+ that I really want. ;)

On 2/2/07, Charles Christie <sonicbhoc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Crap. My hard drive died. Good thing I backed this thing up, huh? Well, now that I've recovered, I will post the code as an attatchment like I said I would. Here you go.


On 1/31/07, Charles Joseph Christie II <sonicbhoc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
I figured I was doing something wrong... I didn't know I could include
attachments. Sorry, this is really the first experience I've had with
a mailing list...

A few e-mails up, I said I was trying to get the game to display the
letters and words you typed correctly in a row. Someone said to put the
sprites in their own group, so I thought he meant class. So that's what
I did. Yet, the text still doesn't show up on screen... What am I doing
wrong?

Yeah. So when I get back to my laptop I'll attach the code instead of
sending it in the body of my message next time. Sorry about that.

On Tue, 30 Jan 2007 16:26:30 -0600
Luke Paireepinart < rabidpoobear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Charles Christie wrote:
> > Aww.... it still doesn't work... am I doin' it right?
> What doesn't work?
> it's easier to give you help if you explain the problem you're having
> and only include
> code snippets you think are relevant...
> I have zero desire to read through all your code and try to figure
> out what the problem is,
> especially since if you think there is a problem you probably know
> approximately where it is occurring...
> :)
> Also attachments are better than including the whole thing in your
> e-mail because then you can be
> sure that it isn't messing up your tabs, and you won't have problems
> with wrapping
> -Luke



Attachment (typinggame.py): application/octet-stream, 5491 bytes
Attachment (helpers.py): application/octet-stream, 1292 bytes

Gmane