Created
February 28, 2014 16:16
-
-
Save amalgamatedclyde/9273885 to your computer and use it in GitHub Desktop.
blit_buffer problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_image(instance, photo, image_slider): | |
"""open selected image, resize and blit into texture""" | |
global currentTexture | |
try: | |
img = PILImage.open(instance.selection[0]) | |
except: pass | |
img = img.resize((180,240), PILImage.BICUBIC) | |
buf = img.tostring() | |
with open('buffer.txt', 'w') as f: | |
f.write(buf) | |
currentTexture = Texture.create(size = (180,240)) | |
currentTexture.blit_buffer(buf, colorfmt='rgb', bufferfmt= 'ubyte') | |
currentTexture.flip_vertical() | |
texture1 = currentTexture.get_region(0,0,180,180) | |
photo.texture = texture1 | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment