func NewPixbufFromFileAtScale(filename string, width, height int, preserve_aspect_ratio bool) (*Pixbuf, *glib.Error) { var err *C.GError ptr := C.CString(filename) defer cfree(ptr) gpixbuf := C.gdk_pixbuf_new_from_file_at_scale(ptr, C.int(width), C.int(height), gbool(preserve_aspect_ratio), &err) if err != nil { return nil, glib.ErrorFromNative(unsafe.Pointer(err)) } return &Pixbuf{ GdkPixbuf: &GdkPixbuf{gpixbuf}, GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)), }, nil }
// PixbufNewFromFileAtScale() is a wrapper around gdk_pixbuf_new_from_file_at_scale(). func PixbufNewFromFileAtScale(fileName string, width, height int, preserveAspectRatio bool) (*Pixbuf, error) { var cerr *C.GError cstr := C.CString(fileName) defer C.free(unsafe.Pointer(cstr)) c := C.gdk_pixbuf_new_from_file_at_scale(cstr, C.int(width), C.int(height), gbool(preserveAspectRatio), &cerr) if c == nil { defer C.g_error_free(cerr) return nil, errors.New(C.GoString((*C.char)(C.error_get_message(cerr)))) } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := wrapPixbuf(obj) runtime.SetFinalizer(obj, (*glib.Object).Unref) return p, nil }
// PixbufNewFromFileAtScale is a wrapper around gdk_pixbuf_new_from_file_at_scale(). func PixbufNewFromFileAtScale(filename string, width, height int, preserveAspectRatio bool) (*Pixbuf, error) { cstr := C.CString(filename) defer C.free(unsafe.Pointer(cstr)) var err *C.GError = nil res := C.gdk_pixbuf_new_from_file_at_scale(cstr, C.int(width), C.int(height), gbool(preserveAspectRatio), &err) if err != nil { defer C.g_error_free(err) return nil, errors.New(C.GoString((*C.char)(err.message))) } if res == nil { return nil, nilPtrErr } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} p := &Pixbuf{obj} runtime.SetFinalizer(obj, (*glib.Object).Unref) return p, nil }
/* Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If %NULL is returned, then @error will be set. Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains. The image will be scaled to fit in the requested size, optionally preserving the image's aspect ratio. When preserving the aspect ratio, a @width of -1 will cause the image to be scaled to the exact given height, and a @height of -1 will cause the image to be scaled to the exact given width. When not preserving aspect ratio, a @width or @height of -1 means to not scale the image at all in that dimension. Negative values for @width and @height are allowed since 2.8. */ func PixbufNewFromFileAtScale(filename string, width int, height int, preserve_aspect_ratio bool) (return__ *Pixbuf, __err__ error) { __cgo__filename := C.CString(filename) __cgo__preserve_aspect_ratio := C.gboolean(0) if preserve_aspect_ratio { __cgo__preserve_aspect_ratio = C.gboolean(1) } var __cgo_error__ *C.GError var __cgo__return__ interface{} __cgo__return__ = C.gdk_pixbuf_new_from_file_at_scale(__cgo__filename, C.int(width), C.int(height), __cgo__preserve_aspect_ratio, &__cgo_error__) C.free(unsafe.Pointer(__cgo__filename)) if __cgo__return__ != nil { return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer())) } if __cgo_error__ != nil { __err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message)))) } return }