JuliaGraphics / Cairo.jl

Bindings to the Cairo graphics library.
Other
87 stars 55 forks source link

Support for cairo_image_surface_get_data? #342

Closed luchr closed 3 years ago

luchr commented 3 years ago

Hello Cairo-team,

I cannot find a way to directly access the data of an image surface (which is done via cairo_image_surface_get_data in Cairo). Is this somewhere hidden in Cairo.jl?

Otherwise. Here is my workaround/implementation:

function image_surface_get_data(surface::CairoSurface{T}) where {T}
    Cairo.flush(surface)
    return ccall(
        (:cairo_image_surface_get_data, Cairo.libcairo),
        Ptr{T},
        (Ptr{Nothing},),
        surface.ptr)
end
lobingera commented 3 years ago

a) Put a PR b) In https://github.com/JuliaGraphics/Cairo.jl/blob/master/test/runtests.jl#L120-L127 you can see how to setup an Image Surface with external data and read from it.

luchr commented 3 years ago

Thank you.