Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for saving flipped Textures #5298

Merged
merged 1 commit into from Jul 22, 2017
Merged

Add support for saving flipped Textures #5298

merged 1 commit into from Jul 22, 2017

Conversation

KeyWeeUsr
Copy link
Contributor

@KeyWeeUsr KeyWeeUsr commented Jul 22, 2017

Example: (Raw → Check image → Flip + Flipped → Check image)

from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.boxlayout import BoxLayout
Builder.load_string('''
<Test>:
    Image:
        id: original
        source: ''  #insert pic
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'Flip'
            on_release: root.flip()
        Button:
            text: 'Flipped'
            on_release: new.texture.save('test.png')
        Button:
            text: 'Raw'
            on_release: original.texture.save('test.png', flipped=False)
    Image:
        id: new
''')
class Test(BoxLayout):
    def flip(self):
        tex = self.ids.original.texture
        tex.flip_vertical()
        self.ids.new.texture = tex
runTouchApp(Test())

As the flipped keyword was set to True by default, this now kind of breaks the API, but as it was just pushed through the warning and let passed through, I think it should be just fine.

Also, I went for more pythonic instead of C solution because it's easier to debug than memcpy or other stuff I saw on various sites. We can still switch to more C-like solution later, if someone finds it necessary, as Kivy isn't a Paint for batch-flipping images. Also bytes(bytearray(pixels)) is for making it compatible both with py2 and py3.

Closes #5262
Closes #4300

@KeyWeeUsr KeyWeeUsr merged commit c3af6db into master Jul 22, 2017
@KeyWeeUsr KeyWeeUsr deleted the flip_save branch July 22, 2017 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant