Ejemplo n.º 1
0
func (v GdkPixbufLoader) Write(buf []byte) (ret bool, err *C.GError) {
	var error *C.GError
	var pbuf *byte
	pbuf = &buf[0]
	ret = gboolean2bool(C.gdk_pixbuf_loader_write(v.PixbufLoader, C.to_gucharptr(unsafe.Pointer(pbuf)), C.gsize(len(buf)), &error))
	err = error
	return
}
Ejemplo n.º 2
0
func (v Loader) Write(buf []byte) (bool, *glib.Error) {
	var err *C.GError
	var pbuf *byte
	pbuf = &buf[0]
	ret := gobool(C.gdk_pixbuf_loader_write(v.GPixbufLoader, C.to_gucharptr(unsafe.Pointer(pbuf)), C.gsize(len(buf)), &err))
	if err != nil {
		return ret, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return ret, nil
}
Ejemplo n.º 3
0
/*
This will cause a pixbuf loader to parse the next @count bytes of
an image.  It will return %TRUE if the data was loaded successfully,
and %FALSE if an error occurred.  In the latter case, the loader
will be closed, and will not accept further writes. If %FALSE is
returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
or #G_FILE_ERROR domains.
*/
func (self *TraitPixbufLoader) Write(buf []byte, count int64) (return__ bool, __err__ error) {
	__header__buf := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
	var __cgo_error__ *C.GError
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_pixbuf_loader_write(self.CPointer, (*C.guchar)(unsafe.Pointer(__header__buf.Data)), C.gsize(count), &__cgo_error__)
	return__ = __cgo__return__ == C.gboolean(1)
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Ejemplo n.º 4
0
// Write() is a wrapper around gdk_pixbuf_loader_write().
func (v *PixbufLoader) Write(data []byte) (n int, err error) {
	// n is set to 0 on error, and set to len(data) otherwise.
	// This is a tiny hacky to satisfy io.Writer and io.WriteCloser,
	// which would allow access to all io and ioutil goodies,
	// and play along nice with go environment.

	if len(data) == 0 {
		return 0, nil
	}

	var cerr *C.GError
	ok := gobool(C.gdk_pixbuf_loader_write(v.Native(), (*C.guchar)(unsafe.Pointer(&data[0])), C.gsize(len(data)), &cerr))
	if !ok {
		defer C.g_error_free(cerr)
		return 0, errors.New(C.GoString((*C.char)(C.error_get_message(cerr))))
	}

	return len(data), nil
}