Skip to content

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

@jockm

Description

@jockm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions