Thread: Python pygames

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    9
    Rep Power
    0

    Python pygames


    Can someone tell me why this is happening.I'm fooling around with pygame and trying to learn on how to program,and I get an error message saying that the program does not recognize the image format.

    import pygame

    pygame.init()
    screen = pygame.display.set_mode((200, 200))
    screen.fill((255, 255, 255))
    pygame.display.set_caption('Hello Pygame')

    ball = pygame.image.load('raspberry.jpg').convert()
    screen.blit(ball, (100, 100))

    pygame.display.update()

    The program does not load raspberry.jpg.It says wrong format.It's in the same directory with the program.

    Thanks
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    I recommend the imagemagick convert program to transfer pictures to formats recognized by pygame. gimp also works. Both of these are open source free programs.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65
    Your JPEG file might be corrupt, try another one.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo