0

My pygame code

bif="images.jpg"
mif="point.png"
import pygame, sys
from pygame.locals import *

pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
background=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(mif).convert_alpha()
while True:
        for event in pygame.event.get():
                if event.type == QUIT:
                        pygame.quit()
                        sys.exit()
        screen.blit(background, (0,0))

Error message

Traceback (most recent call last):
  File "game.py", line 8, in <module>
    background=pygame.image.load(bif).convert()
pygame.error: File is not a Windows BMP file

I tried this link but this is also not working

Why are my pygame images not loading?

Community
  • 1
  • 1
user69910
  • 971
  • 2
  • 9
  • 14
  • It complains about the format of the image -> which image formats is your pygame able to load? Maybe you have to install something additionally to support other formats. (you put .jpg inside and .bmp is expected. Find out, why it expects .bmp) – User Jun 10 '13 at 12:59
  • I tried bmp image , but it didn't worked. – user69910 Jun 10 '13 at 13:28
  • In what way didn't it work? Does it also say `pygame.error: File is not a Windows BMP file`? – Armali Jun 12 '13 at 07:03
  • Yes same error as in case of jpeg – user69910 Jun 12 '13 at 07:36

2 Answers2

2

From pygame documentation:

By default it can only load uncompressed BMP images. When built with full image support, the pygame.image.load() function can support the following formats. JPG ...

So, if you want JPG and PNG images, you have to build with full image support.

Armali
  • 18,255
  • 14
  • 57
  • 171
0

I highly doubt this will fix your problem, however if anyone else has this exact issue, I want them to see it, as it happened to me, from using a Python version on Microsoft Marketplace.

If it cannot find images specfically, however can once you type the entire path. Meaning a python script cannot find images in the exact same directory and even folder it may be related to something very random, I have not saw on any answers, or even close.

In window there is a .dll file named FileSyncShell64.dll this can go missing, and cause an idle.exe - Bad Image when saving depending on where Python is, and what version and other things. The point is it is the OS that needs the file. So find the correct file on google and place it in the correct spot, if you get an error message when saving it will have the address of where it was or should be. This happened to me somehow, because for some reason the Marketplace put Python in a OneDrive folder, followed by a number DNS or IP it seems, then amd64 when the .dll that is missing.

Just letting anyone know who is having trouble if they already exhausted every other method, like adding the compelete path, maing sure the images are located in the correct spot, making sure python is in Path and everything else possible, this is a rare fix, however none the less it apparently happens. Causing only entire addresses to work when doing anything with any file location, making everything a nightmare, for a possible long time.

Mizat
  • 11
  • 3