comparison cagou/core/image.py @ 312:772c170b47a9

Python3 port: /!\ Cagou now runs with Python 3.6+ Port has been done in the same way as for backend (check backend commit b2d067339de3 message for details).
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:14:22 +0200
parents 1b835bcfa663
children 4d660b252487
comparison
equal deleted inserted replaced
311:a0d978d3ce84 312:772c170b47a9
56 del im 56 del im
57 # we can't use im.tobytes as it would use the 57 # we can't use im.tobytes as it would use the
58 # internal decompressed representation from pillow 58 # internal decompressed representation from pillow
59 # and im.save would need processing to handle format 59 # and im.save would need processing to handle format
60 data = io.BytesIO(open(filename, "rb").read()) 60 data = io.BytesIO(open(filename, "rb").read())
61 cache_filename = u"{}.{}".format(filename,ext) # needed for kivy's Image to use cache 61 cache_filename = "{}.{}".format(filename,ext) # needed for kivy's Image to use cache
62 self._coreimage = ci = CoreImage(data, ext=ext, 62 self._coreimage = ci = CoreImage(data, ext=ext,
63 filename=cache_filename, mipmap=mipmap, 63 filename=cache_filename, mipmap=mipmap,
64 anim_delay=self.anim_delay, 64 anim_delay=self.anim_delay,
65 keep_data=self.keep_data, 65 keep_data=self.keep_data,
66 nocache=self.nocache) 66 nocache=self.nocache)
67 except Exception as e: 67 except Exception as e:
68 log.warning(u"Can't load image: {}".format(e)) 68 log.warning("Can't load image: {}".format(e))
69 self._coreimage = ci = None 69 self._coreimage = ci = None
70 70
71 if ci: 71 if ci:
72 ci.bind(on_texture=self._on_tex_change) 72 ci.bind(on_texture=self._on_tex_change)
73 self.texture = ci.texture 73 self.texture = ci.texture