Skip to content Skip to sidebar Skip to footer

Both Image.export_to_png And Image.export_as_image Not Working

I have the following code: from kivy.app import App from kivy.uix.image import Image class MyApp(App): def build(self): my_image = Image(source='test.png') wi

Solution 1:

Looks like you just need to wait for the next frame, probably for OpenGL initialisation reasons:

from kivy.app import App
from kivy.uix.image import Image
from kivy.graphics import Triangle
from kivy.clock import Clock

classMyApp(App):

    defbuild(self):
        self.my_image = Image(source='test.png')
        with self.my_image.canvas:
            Triangle(point=(0, 0, 30, 30, 60, 0))

        Clock.schedule_once(self.export, 1)
        return self.my_image

    defexport(self, dt):
        self.my_image.export_to_png('test2.png')
        self.my_image.export_as_image().save('test3.png')


myapp = MyApp().run()

EDIT: I've done my research and found out that it is caused by the fact that these functions (I'm only sure about image.export_to_png but image.export_as_image provides the same result) export not the widget itself but rather canvas of the widget.

There isn't anything to the widget's appearance except what it draws on its canvas.

I don't understand your final questions.

Post a Comment for "Both Image.export_to_png And Image.export_as_image Not Working"