Closed gen2brain closed 9 years ago
I think this may be related https://github.com/golang/go/issues/7958#issuecomment-66094578
I fixed it like this:
diff -ur go-cairo.orig/surface.go go-cairo/surface.go
--- go-cairo.orig/surface.go 2015-10-16 03:31:51.000000000 +0200
+++ go-cairo/surface.go 2015-10-15 18:49:33.000000000 +0200
@@ -16,10 +16,13 @@
"github.com/ungerik/go-cairo/extimage"
)
+type Cairo_surface *C.cairo_surface_t
+type Cairo_context *C.cairo_t
+
// Golang struct to hold both a cairo surface and a cairo context
type Surface struct {
- surface *C.cairo_surface_t
- context *C.cairo_t
+ surface Cairo_surface
+ context Cairo_context
}
func NewSurface(format Format, width, height int) *Surface {
@@ -30,7 +33,7 @@
// NewSurfaceFromC creates a new surface from C data types.
// This is useful, if you already obtained a surface by
// using a C library, for example an XCB surface.
-func NewSurfaceFromC(s *C.cairo_surface_t, c *C.cairo_t) *Surface {
+func NewSurfaceFromC(s Cairo_surface, c Cairo_context) *Surface {
return &Surface{surface: s, context: c}
}
And then I called it in go-poppler like this:
return cairo.NewSurfaceFromC((cairo.Cairo_surface)(unsafe.Pointer(ci)), (cairo.Cairo_context)(unsafe.Pointer(ctx)))
I am trying to use https://github.com/cheggaaa/go-poppler to extract images from pdf, but I am getting this during build: golang/src/github.com/cheggaaa/go-poppler/image.go:24: cannot use ci (type C.struct__cairo_surface) as type cairo.C.struct__cairo_surface in argument to cairo.NewSurfaceFromC golang/src/github.com/cheggaaa/go-poppler/image.go:24: cannot use ctx (type C.struct__cairo) as type cairo.C.struct__cairo in argument to cairo.NewSurfaceFromC
Do you have and idea how it can be fixed? I also filled issue there https://github.com/cheggaaa/go-poppler/issues/1 .