Skip to content

Instantly share code, notes, and snippets.

@amalgamatedclyde
Last active August 29, 2015 13:56
Show Gist options
  • Save amalgamatedclyde/8916255 to your computer and use it in GitHub Desktop.
Save amalgamatedclyde/8916255 to your computer and use it in GitHub Desktop.
this works on linux but not android.
def change_image(instance, photo):
"""open selected image, resize and blit into texture"""
global currentTexture
##try:
img = PILImage.open(instance.selection[0])
##print img
currentTexture = Texture.create(size= (180,240))
img2 = img.resize((180,240), PILImage.BICUBIC)
buf = img2.tostring()
currentTexture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')
currentTexture.flip_vertical()
texture1 = currentTexture.get_region(0,0,180,180)
photo.texture = texture1
#except: pass
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment