illume avatar illume committed 064cd23

Adding test for issue #131.

Unable to Surface.convert(32) some 1-bit images.

Thanks Dean Serenevy.

Comments (0)

Files changed (3)

Add a comment to this file

examples/data/brick.png

Added
New image
Added
New image

test/surface_test.py

 
 if is_pygame_pkg:
     from pygame.tests import test_utils
-    from pygame.tests.test_utils import test_not_implemented, unittest
+    from pygame.tests.test_utils import test_not_implemented, unittest, example_path
     try:
         from pygame.tests.test_utils.arrinter import *
     except ImportError:
         pass
 else:
     from test import test_utils
-    from test.test_utils import test_not_implemented, unittest
+    from test.test_utils import test_not_implemented, unittest, example_path
     try:
         from test.test_utils.arrinter import *
     except ImportError:
         source.set_at((0, 0), color)
         target.blit(source, (0, 0))
 
+    def test_image_convert_bug_131(self):
+        # Bitbucket bug #131: Unable to Surface.convert(32) some 1-bit images.
+        # https://bitbucket.org/pygame/pygame/issue/131/unable-to-surfaceconvert-32-some-1-bit
+        pygame.display.init()
+        pygame.display.set_mode((640,480))
+
+        im  = pygame.image.load(example_path(os.path.join("data", "city.png")))
+        im2 = pygame.image.load(example_path(os.path.join("data", "brick.png")))
+
+        self.assertEquals( im.get_palette(),  ((0, 0, 0, 255), (255, 255, 255, 255)) )
+        self.assertEquals( im2.get_palette(), ((0, 0, 0, 255), (0, 0, 0, 255)) )
+
+        self.assertEqual(repr(im.convert(32)),  '<Surface(24x24x32 SW)>')
+        self.assertEqual(repr(im2.convert(32)), '<Surface(469x137x32 SW)>')
+
     def todo_test_convert(self):
 
         # __doc__ (as of 2008-08-02) for pygame.surface.Surface.convert:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.