Exemplo n.º 1
0
func NewLoaderWithType(image_type string) (loader *Loader, err *C.GError) {
	var error *C.GError
	ptr := C.CString(image_type)
	defer C.free_string(ptr)
	loader = &Loader{C.gdk_pixbuf_loader_new_with_type(ptr, &error)}
	err = error
	return
}
Exemplo n.º 2
0
func NewLoaderWithType(image_type string) (loader *Loader, err *glib.Error) {
	var gerr *C.GError
	ptr := C.CString(image_type)
	defer cfree(ptr)
	loader = &Loader{
		C.gdk_pixbuf_loader_new_with_type(ptr, &gerr)}
	if gerr != nil {
		err = glib.ErrorFromNative(unsafe.Pointer(gerr))
	}
	return
}
Exemplo n.º 3
0
/*
Creates a new pixbuf loader object that always attempts to parse
image data as if it were an image of type @image_type, instead of
identifying the type automatically. Useful if you want an error if
the image isn't the expected type, for loading image formats
that can't be reliably identified by looking at the data, or if
the user manually forces a specific type.

The list of supported image formats depends on what image loaders
are installed, but typically "png", "jpeg", "gif", "tiff" and
"xpm" are among the supported formats. To obtain the full list of
supported image formats, call gdk_pixbuf_format_get_name() on each
of the #GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().
*/
func PixbufLoaderNewWithType(image_type string) (return__ *PixbufLoader, __err__ error) {
	__cgo__image_type := C.CString(image_type)
	var __cgo_error__ *C.GError
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_loader_new_with_type(__cgo__image_type, &__cgo_error__)
	C.free(unsafe.Pointer(__cgo__image_type))
	if __cgo__return__ != nil {
		return__ = NewPixbufLoaderFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Exemplo n.º 4
0
Arquivo: gdk.go Projeto: gotk3/gotk3
// PixbufLoaderNewWithType() is a wrapper around gdk_pixbuf_loader_new_with_type().
func PixbufLoaderNewWithType(t string) (*PixbufLoader, error) {
	var err *C.GError

	cstr := C.CString(t)
	defer C.free(unsafe.Pointer(cstr))

	c := C.gdk_pixbuf_loader_new_with_type((*C.char)(cstr), &err)
	if err != nil {
		defer C.g_error_free(err)
		return nil, errors.New(C.GoString((*C.char)(err.message)))
	}

	if c == nil {
		return nil, nilPtrErr
	}

	//TODO this should be some wrap object
	obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
	p := &PixbufLoader{obj}
	runtime.SetFinalizer(obj, (*glib.Object).Unref)
	return p, nil
}