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

I believe there may be a bug in efl.evas_object_image.pxi.image_data_set() #13

Open
jockm opened this issue Oct 4, 2024 · 0 comments
Open

Comments

@jockm
Copy link

jockm commented Oct 4, 2024

Disclaimer:. I am very new to EFL and doubly so Python-EFL, but I had a program where I was trying to update the image data of an image control.

So I cobbled together some code that looked like this:

    def updateImage(self, imageControl, rgbaImage):
        w, h = rgbaImage.size
        d = rgbaImage.tobytes()

        evas_image = imageControl
        evas_image.image_size_set(w, h)
        evas_image.image_data_set(d)

        # Force the Evas image to reload and display the new data
        evas_image.image_data_update_add(0, 0, w, h)
        imageControl.show()

and the line evas_image.image_data_set(d) would throw and exception that would read:

ValueError: buffer size (1) is smaller than expected (7680000)!

So I dug into the code on github and in efl.evas_object_image.pxi, in the method .image_data_set() we see this code:

expected_size = _data_size_get(self.obj)
        if view.itemsize < expected_size:
            raise ValueError(
                "buffer size (%d) is smaller than expected (%d)!" % (
                    view.itemsize, expected_size
                    )
                )

Where we see view.itemsize being compared against expected_size. However the documentation for itemsize says:

Item size in bytes of a single element.

Thus view.itemsize will always be smaller than the size of the whole buffer, and always throw an exception.

Now it's completely possible I am misunderstanding what you pass into to image_data_set(), but the documentation in not the most clear

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

No branches or pull requests

1 participant