Esempio n. 1
0
func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
	if len(options)%2 != 0 {
		argumentPanic("Save options must be even (key and value)")
	}

	pfilename := C.CString(filename)
	defer cfree(pfilename)
	psavetype := C.CString(savetype)
	defer cfree(psavetype)

	klen := len(options) / 2
	keys := C.makeCstrv(C.int(klen + 1))
	vals := C.makeCstrv(C.int(klen + 1))
	for i := 0; i < klen; i++ {
		C.setCstr(keys, C.int(i), C.CString(options[2*i]))
		C.setCstr(vals, C.int(i), C.CString(options[2*i+1]))
	}
	C.setCstr(keys, C.int(klen), nil)
	C.setCstr(vals, C.int(klen), nil)
	defer func() {
		for i := 0; i < klen; i++ {
			cfree(C.getCstr(keys, C.int(i)))
			cfree(C.getCstr(vals, C.int(i)))
		}
		C.freeCstrv(keys)
		C.freeCstrv(vals)
	}()

	var err *C.GError
	C.gdk_pixbuf_savev(p.GPixbuf, pfilename, psavetype, keys, vals, &err)
	if err != nil {
		return glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return nil
}
Esempio n. 2
0
/*
Saves pixbuf to a file in @type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
If @error is set, %FALSE will be returned.
See gdk_pixbuf_save () for more details.
*/
func (self *TraitPixbuf) Savev(filename string, type_ string, option_keys []string, option_values []string) (return__ bool, __err__ error) {
	__cgo__filename := C.CString(filename)
	__cgo__type_ := C.CString(type_)
	__header__option_keys := (*reflect.SliceHeader)(unsafe.Pointer(&option_keys))
	__header__option_values := (*reflect.SliceHeader)(unsafe.Pointer(&option_values))
	var __cgo_error__ *C.GError
	var __cgo__return__ C.gboolean
	__cgo__return__ = C.gdk_pixbuf_savev(self.CPointer, __cgo__filename, __cgo__type_, (**C.char)(unsafe.Pointer(__header__option_keys.Data)), (**C.char)(unsafe.Pointer(__header__option_values.Data)), &__cgo_error__)
	C.free(unsafe.Pointer(__cgo__filename))
	C.free(unsafe.Pointer(__cgo__type_))
	return__ = __cgo__return__ == C.gboolean(1)
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}