1

I wanted to blit an image in python, a png image. But for some reason about half the image has the wrong pixel colours, it looks all messy, having random coloured pixels in it. I have made a few games on my Macbook Pro (OSX) using pygame with python 3.4, and I had no trouble when it came to blitting images. Here's the code:

import pygame
import os

w = pygame.display.set_mode((300,300))

bug = os.path.join("/Users/Snyman/Desktop/images/double-block_spm_R.png")
bug = pygame.image.load(bug).convert_alpha()
bug = pygame.transform.scale(bug,(64,64))

loop = True

while loop:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            loop = False

    w.fill((255,255,255))
    w.blit(bug,(10,10))
    pygame.display.update()

pygame.quit()

"bug" is my image

Coding Tunes
  • 75
  • 1
  • 9
  • it looks like broken file. check image in some image viewer – furas Feb 01 '16 at 08:21
  • I did, but it was perfectly fine! – Coding Tunes Feb 01 '16 at 08:25
  • try code without `transform.scale` or/and without `convert_alpha`. – furas Feb 01 '16 at 08:30
  • I did try it without convert_alpha() but it still won't display the image correctly, i don't think it has something to do with the code, cause some images blit perfectly – Coding Tunes Feb 01 '16 at 09:16
  • did you try without `transform.scale()` . It can be some problem with PyGame only on OSX. I think I saw this kind of question on SO but probably without answer. – furas Feb 01 '16 at 09:20
  • btw: you don't need to use `os.path.join`. it useful with more than one argument. With one argument it do nothing. – furas Feb 01 '16 at 10:13
  • as I said before - it can be problem on OSX - i found this http://stackoverflow.com/questions/34668345/pygame-on-mac-error-with-loading-images – furas Feb 01 '16 at 11:10
  • this problem has nothing to do with the fact that i'm on OSX, or the os.path.join() or not even the transform.scale(), like I said before, I had no trouble with blitting images (and I used all of the above). it wasn't until this morning when the freaky stuff happened – Coding Tunes Feb 01 '16 at 13:24
  • I think i found the problem! I have been doing some research and it appears that there are very similar glitches on other Macbook Pro 10.11 users, I think it's called an SDL_image rendering issue, does anyone know how to resolve it perhaps? – Coding Tunes Feb 01 '16 at 13:59
  • did you see link in my comment above ? There is information about this issue and some link in answer. And there is information that `downgrading ` SDL to 1.2.10 can helps. – furas Feb 01 '16 at 14:08
  • Are you on El Capitan? http://stackoverflow.com/questions/34757499/sdl-image-visual-glitch-on-os-x-el-capitan/34758362#34758362 – Chris Feb 01 '16 at 21:10

0 Answers0