Skip to content

Instantly share code, notes, and snippets.

@amalgamatedclyde
Created February 28, 2014 16:16
Show Gist options
  • Save amalgamatedclyde/9273885 to your computer and use it in GitHub Desktop.
Save amalgamatedclyde/9273885 to your computer and use it in GitHub Desktop.
blit_buffer problem
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