1. pygame
  2. pygame
  3. pygame

Issues

Issue #39 resolved

pygame-1.9.1release - endian problem saving an image in png format

René Dudfield
created an issue

== Jens Restemeier, 2009-09-08 12:09:36 -0700

{{{ Created attachment 28 Example test script

When saving an image in png format the channels seem to be reversed. I attached a script, on Windows they produce the same image, on OSX/powerpc they produce the attached images, }}}


Attachments: [[http://www.pygame.org/old_bug_attachments/28/pngtest.py| pngtest.py]]

== Jens Restemeier, 2009-09-08 12:10:43 -0700

{{{ Created attachment 29 PNG test image produced on MacOS powerpc }}}


Attachments: [[http://www.pygame.org/old_bug_attachments/29/test.png| test.png]]

== Jens Restemeier, 2009-09-08 12:11:31 -0700

{{{ Created attachment 30 TGA test image produced on MacOS powerpc - this is how it should look like. }}}


Attachments: [[http://www.pygame.org/old_bug_attachments/30/test.tga| test.tga]]

Comments (8)

  1. René Dudfield reporter
    • changed status to open
    • changed milestone to 1.9.2

    Thanks Jens.

    Here is the test code inline the comment to make it easier to see.

    import pygame, os
    from pygame.locals import *
    
    # Set SDL to use the dummy NULL video driver,
    #   so it doesn't need a windowing system.
    os.environ["SDL_VIDEODRIVER"] = "dummy"
    
    if True:
        # Some platforms need to init the display for some parts of pygame.
        import pygame.display
        pygame.display.init()
        screen = pygame.display.set_mode((1,1))
    
    def main():
        test = pygame.Surface((256, 256), flags=SRCALPHA, depth=32)
        for y in xrange(256):
            for x in xrange(256):
                test.set_at((x, y), (x,y,(x + y) % 256, (((x ^ y) >> 4) & 1) * 127 + 128))
        for ext in ["tga", "png", "bmp", "jpg"]:
            pygame.image.save(test, "test.%s" % ext)
    
    if __name__ == "__main__":
        main()
    

    It seems the set_at() call does some bit fiddling, which I'm weary of.

    Also need to confirm this fails on PPC, which I don't have access too test on.

    The test could be changed to read the lossless formats like tga, png and bmp to make sure they read back the colours correctly. Then this could be used as a unit test easily.

  2. Olivier Pirson

    I have the same problem (save PNG reverse channels) with this configuration:

    • Debian Wheezy AMD 64
    • Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2]
    • Pygame 1.9.2a0

    It's ok with:

    • Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2]
    • Pygame 1.9.1release
  3. Log in to comment