Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions gdk/gdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,36 @@ func PixbufNewFromFile(filename string) (*Pixbuf, error) {
return p, nil
}

// PixbufNewFromFileAtScale is a wrapper around gdk_pixbuf_new_from_file_at_scale().
func PixbufNewFromFileAtScale(filename string, width, height int, preserve_aspect_ratio bool) (*Pixbuf, error) {
var err *C.GError = nil
c := C.gdk_pixbuf_new_from_file_at_scale(C.CString(filename), C.int(width), C.int(height), gbool(preserve_aspect_ratio), &err)
if c == nil {
defer C.g_error_free(err)
return errors.New(C.GoString((*C.char)(err.message)))
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
p := &Pixbuf{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return p, nil
}

// PixbufNewFromFileAtSize is a wrapper around gdk_pixbuf_new_from_file_at_size().
func PixbufNewFromFileAtSize(filename string, width, height int) (*Pixbuf, error) {
var err *C.GError = nil
c := C.gdk_pixbuf_new_from_file_at_size(C.CString(filename), C.int(width), C.int(height), &err)
if c == nil {
defer C.g_error_free(err)
return errors.New(C.GoString((*C.char)(err.message)))
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
p := &Pixbuf{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return p, nil
}

// ScaleSimple is a wrapper around gdk_pixbuf_scale_simple().
func (v *Pixbuf) ScaleSimple(destWidth, destHeight int, interpType InterpType) (*Pixbuf, error) {
c := C.gdk_pixbuf_scale_simple(v.native(), C.int(destWidth),
Expand Down