I am trying to port this code to work on Mac, and it does work. The only issue is reading .jpg files. It reads .png files fine, but throws the following exception. If I comment out the raise e in canvas.py it works, but doesn't give me images. Any clue as to what this exception means?
The Mac: /Users/kpomeroy/Downloads/eopk-0.9.32-src/> python program.py Traceback (most recent call last): File "program.py", line 44, in <module> frame = EoPK.MainWindow(None, ID_MAIN_WINDOW, EOPK_APPNAME) File "/Users/kpomeroy/Downloads/eopk-0.9.32-src/EoPK.py", line 855, in init self.cardPreview = preview.CardPreviewWindow(splitterLeft, id=ID_CARD_PREVIEW) File "/Users/kpomeroy/Downloads/eopk-0.9.32-src/preview.py", line 100, in init self.oglCanvas = CardPreviewCanvas(self, style=wx.BORDER_THEME) File "/Users/kpomeroy/Downloads/eopk-0.9.32-src/preview.py", line 46, in init canvas.L5RCanvas.init(self, parent, id, *args, **kwargs) File "/Users/kpomeroy/Downloads/eopk-0.9.32-src/canvas.py", line 62, in init self.texFateBack = self.LoadTexture("images/fate_back.jpg") File "/Users/kpomeroy/Downloads/eopk-0.9.32-src/canvas.py", line 78, in LoadTexture raise e
Comment #1
Posted on Feb 1, 2010 by Helpful KangarooUnfortunately, I have no idea. I'm looking into the issue, but I would set a break point in the LoadTextureInto() function just below it (or add exception handling), as I feel that this is the function that initially throws the error.
Try this for the LoadTextureInto function:
def LoadTextureInto(self, fn, texid): """Load a texture into an OpenGL texture object.""" self.SetCurrent() try: # Open it with PIL. img = Image.open(fn)
# Make sure it has dimensions 2^n!
img = img.resize((next_power_of_two(img.size[0]), next_power_of_two(img.size[1])))
(width, height) = img.size
glBindTexture(GL_TEXTURE_2D, texid)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, {"RGBA":GL_RGBA,
"RGB":GL_RGB}[img.mode], GL_UNSIGNED_BYTE, img.tostring()) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) except Exception e: ##breakpoint goes here! print "%s" % (e) raise e
This should tell you if this is the error. I'll read up more.
Comment #2
Posted on Feb 1, 2010 by Swift BearThe following works. I can load the image, and even view its info. But if I do an img.show() or anything else, it fails. Just doing a return 'works' but doesn't load any of the .jpg images.
http://www.pomeroytx.com/uploads/grabit-os-x-k28502i13cw2tcktmmfwrdegu8q8cz.png
# Open it with PIL.
img = Image.open(fn)
print img.format, img.size, img.mode
return img
# Make sure it has dimensions 2^n!
img = img.resize((next_power_of_two(img.size[0]), next_power_of_two(img.size[1])))
Comment #3
Posted on Feb 3, 2010 by Swift BearApparently OS X and python just don't play well together (out of the box at least). I have it working, but don't yet know how to get a *.app file (a .exe equivalent) that is distributable en mass.
http://www.p16blog.com/p16/2008/05/appengine-installing-pil-on-os-x-1053.html
Comment #4
Posted on Feb 24, 2010 by Helpful Kangaroo(No comment was entered for this change.)
Status: Done
Labels:
Type-Defect
Priority-Low
Component-UI