コード例 #1
0
ファイル: gdkpixbuf_traits.go プロジェクト: reusee/ggir
/*
Queries a pointer to the pixel data of a pixbuf.
*/
func (self *TraitPixbuf) GetPixelsWithLength() (length uint, return__ []byte) {
	var __cgo__length C.guint
	var __cgo__return__ *C.guchar
	__cgo__return__ = C.gdk_pixbuf_get_pixels_with_length(self.CPointer, &__cgo__length)
	length = uint(__cgo__length)
	defer func() { return__ = C.GoBytes(unsafe.Pointer(__cgo__return__), C.int(length)) }()
	return
}
コード例 #2
0
ファイル: gdk.go プロジェクト: visionect/gotk3
// GetPixels is a wrapper around gdk_pixbuf_get_pixels_with_length().
// A Go slice is used to represent the underlying Pixbuf data array, one
// byte per channel.
func (v *Pixbuf) GetPixels() (channels []byte) {
	var length C.guint
	c := C.gdk_pixbuf_get_pixels_with_length(v.native(), &length)
	sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&channels))
	sliceHeader.Data = uintptr(unsafe.Pointer(c))
	sliceHeader.Len = int(length)
	sliceHeader.Cap = int(length)
	// To make sure the slice doesn't outlive the Pixbuf, add a reference
	v.Ref()
	runtime.SetFinalizer(&channels, func(_ *[]byte) {
		v.Unref()
	})
	return
}
コード例 #3
0
ファイル: gdk.go プロジェクト: pmcoder/gotk3
// GetPixels is a wrapper around gdk_pixbuf_get_pixels_with_length().
// A Go slice is used to represent the underlying Pixbuf data array, one
// byte per channel.
func (v *Pixbuf) GetPixels() []byte {
	var length C.guint
	c := C.gdk_pixbuf_get_pixels_with_length(v.Native(), &length)
	return C.GoBytes(unsafe.Pointer(c), (C.int)(length))
}