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

Copying part of a surface to another surface #35

Open
StephanvanSchaik opened this issue Oct 24, 2018 · 0 comments
Open

Copying part of a surface to another surface #35

StephanvanSchaik opened this issue Oct 24, 2018 · 0 comments

Comments

@StephanvanSchaik
Copy link

StephanvanSchaik commented Oct 24, 2018

Hi,

Using cairocffi, one can copy part of the surface to another by doing something along the lines of:

ctx = surface.get_new_context()
ctx.set_source_surface(old_surface._cairo_surface, 0, 0)
ctx.rectangle(x, y, width, height)
ctx.fill()

I have tried to use gizeh.rectangle() in combination with gizeh.ImagePattern() using the old surface to achieve the same effect, but passing a gizeh.Surface to gizeh.ImagePattern() does not seem to work. I saw that it should be possible to use surface.get_npimage() instead, but I rather avoid the overhead of converting it to a numpy array and back to a Cairo surface.

Is there another way to achieve the same effect?

edit: I also tried using surface.get_npimage() and passing that to gizeh.ImagePattern() instead, but that also fails with:
"TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'"

Yours sincerely,
Stephan.

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