// Code generated by cmd/cgo; DO NOT EDIT. //line /home/josie/.cache/paru/clone/wiiudownloader/src/pkg/mod/github.com/gotk3/gotk3@v0.6.5-0.20240618185848-ff349ae13f56/gdk/pixbuf.go:1:1 // Same copyright and license as the rest of the files in this project package gdk // #cgo pkg-config: gdk-3.0 glib-2.0 gobject-2.0 // #include // #include "gdk.go.h" // #include "pixbuf.go.h" import _ "unsafe" import ( "errors" "reflect" "runtime" "strconv" "unsafe" "github.com/gotk3/gotk3/glib" ) func init() { tm := []glib.TypeMarshaler{ // Enums {glib.Type(( /*line :23:14*/_Cfunc_gdk_pixbuf_alpha_mode_get_type /*line :23:45*/)()), marshalPixbufAlphaMode}, // Objects/Interfaces {glib.Type(( /*line :26:14*/_Cfunc_gdk_pixbuf_get_type /*line :26:34*/)()), marshalPixbuf}, {glib.Type(( /*line :27:14*/_Cfunc_gdk_pixbuf_animation_get_type /*line :27:44*/)()), marshalPixbufAnimation}, {glib.Type(( /*line :28:14*/_Cfunc_gdk_pixbuf_loader_get_type /*line :28:41*/)()), marshalPixbufLoader}, } glib.RegisterGValueMarshalers(tm) } /* * Constants */ // TODO: // GdkPixbufError // PixbufRotation is a representation of GDK's GdkPixbufRotation. type PixbufRotation int const ( PIXBUF_ROTATE_NONE PixbufRotation = ( /*line :44:50*/_Ciconst_GDK_PIXBUF_ROTATE_NONE /*line :44:73*/) PIXBUF_ROTATE_COUNTERCLOCKWISE PixbufRotation = ( /*line :45:50*/_Ciconst_GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE /*line :45:85*/) PIXBUF_ROTATE_UPSIDEDOWN PixbufRotation = ( /*line :46:50*/_Ciconst_GDK_PIXBUF_ROTATE_UPSIDEDOWN /*line :46:79*/) PIXBUF_ROTATE_CLOCKWISE PixbufRotation = ( /*line :47:50*/_Ciconst_GDK_PIXBUF_ROTATE_CLOCKWISE /*line :47:78*/) ) // PixbufAlphaMode is a representation of GDK's GdkPixbufAlphaMode. type PixbufAlphaMode int const ( GDK_PIXBUF_ALPHA_BILEVEL PixbufAlphaMode = ( /*line :54:45*/_Ciconst_GDK_PIXBUF_ALPHA_BILEVEL /*line :54:70*/) GDK_PIXBUF_ALPHA_FULL PixbufAlphaMode = ( /*line :55:45*/_Ciconst_GDK_PIXBUF_ALPHA_FULL /*line :55:67*/) ) func marshalPixbufAlphaMode(p uintptr) (interface{}, error) { c := ( /*line :59:7*/_Cfunc_g_value_get_enum /*line :59:24*/)((* /*line :59:28*/_Ctype_GValue /*line :59:36*/)(unsafe.Pointer(p))) return PixbufAlphaMode(c), nil } /* * GdkPixbuf */ // PixbufGetType is a wrapper around gdk_pixbuf_get_type(). func PixbufGetType() glib.Type { return glib.Type(( /*line :69:19*/_Cfunc_gdk_pixbuf_get_type /*line :69:39*/)()) } // Pixbuf is a representation of GDK's GdkPixbuf. type Pixbuf struct { *glib.Object } // native returns a pointer to the underlying GdkPixbuf. func (v *Pixbuf) native() * /*line :78:28*/_Ctype_GdkPixbuf /*line :78:39*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :83:23*/p; _cgoCheckPointer(_cgo0, nil); return /*line :83:25*/_Cfunc_toGdkPixbuf(_cgo0); }() } // Native returns a pointer to the underlying GdkPixbuf. func (v *Pixbuf) Native() uintptr { return uintptr(unsafe.Pointer(v.native())) } func (v *Pixbuf) NativePrivate() * /*line :91:35*/_Ctype_GdkPixbuf /*line :91:46*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :96:23*/p; _cgoCheckPointer(_cgo0, nil); return /*line :96:25*/_Cfunc_toGdkPixbuf(_cgo0); }() } func marshalPixbuf(p uintptr) (interface{}, error) { c := ( /*line :100:7*/_Cfunc_g_value_get_object /*line :100:26*/)((* /*line :100:30*/_Ctype_GValue /*line :100:38*/)(unsafe.Pointer(p))) obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} return &Pixbuf{obj}, nil } // PixbufNew is a wrapper around gdk_pixbuf_new(). func PixbufNew(colorspace Colorspace, hasAlpha bool, bitsPerSample, width, height int) (*Pixbuf, error) { c := ( /*line :107:7*/_Cfunc_gdk_pixbuf_new /*line :107:22*/)( /*line :107:24*/_Ctype_GdkColorspace /*line :107:39*/(colorspace), gbool(hasAlpha), /*line :108:3*/_Ctype_int /*line :108:8*/(bitsPerSample), /*line :108:25*/_Ctype_int /*line :108:30*/(width), /*line :108:39*/_Ctype_int /*line :108:44*/(height)) if c == nil { return nil, nilPtrErr } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} //obj.Ref() runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // File Loading // PixbufNewFromFile is a wrapper around gdk_pixbuf_new_from_file(). func PixbufNewFromFile(filename string) (*Pixbuf, error) { cstr := ( /*line :124:10*/_Cfunc_CString /*line :124:18*/)(filename) defer func() func() { _cgo0 := /*line :125:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :125:36*/_Cfunc_free(_cgo0); }}()() var err * /*line :127:11*/_Ctype_GError /*line :127:19*/ c := func() *_Ctype_struct__GdkPixbuf{ var _cgo0 *_Ctype_char = /*line :128:34*/(*_Ctype_char /*line :128:42*/)(cstr); _cgoBase1 := /*line :128:51*/&err; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :128:56*/_Cfunc_gdk_pixbuf_new_from_file(_cgo0, _cgo1); }() if c == nil { defer func() func() { _cgo0 := /*line :130:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :130:28*/_Cfunc_g_error_free(_cgo0); }}()() return nil, errors.New(( /*line :131:26*/_Cfunc_GoString /*line :131:35*/)((* /*line :131:39*/_Ctype_char /*line :131:45*/)(err.message))) } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} //obj.Ref() runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // Image Data in Memory // PixbufNewFromData is a wrapper around gdk_pixbuf_new_from_data(). func PixbufNewFromData(pixbufData []byte, cs Colorspace, hasAlpha bool, bitsPerSample, width, height, rowStride int) (*Pixbuf, error) { arrayPtr := (* /*line :145:16*/_Ctype_guchar /*line :145:24*/)(unsafe.Pointer(&pixbufData[0])) c := ( /*line :147:7*/_Cfunc_gdk_pixbuf_new_from_data /*line :147:32*/)( arrayPtr, /*line :149:3*/_Ctype_GdkColorspace /*line :149:18*/(cs), gbool(hasAlpha), /*line :151:3*/_Ctype_int /*line :151:8*/(bitsPerSample), /*line :152:3*/_Ctype_int /*line :152:8*/(width), /*line :153:3*/_Ctype_int /*line :153:8*/(height), /*line :154:3*/_Ctype_int /*line :154:8*/(rowStride), nil, // TODO: missing support for GdkPixbufDestroyNotify nil, ) if c == nil { return nil, nilPtrErr } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} //obj.Ref() runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // PixbufNewFromDataOnly is a convenient alternative to PixbufNewFromData() and also a wrapper around gdk_pixbuf_new_from_data(). func PixbufNewFromDataOnly(pixbufData []byte) (*Pixbuf, error) { pixbufLoader, err := PixbufLoaderNew() if err != nil { return nil, err } return pixbufLoader.WriteAndReturnPixbuf(pixbufData) } // PixbufNewFromResource is a wrapper around gdk_pixbuf_new_from_resource() func PixbufNewFromResource(resourcePath string) (*Pixbuf, error) { var gerr * /*line :182:12*/_Ctype_GError /*line :182:20*/ cstr := ( /*line :184:10*/_Cfunc_CString /*line :184:18*/)(resourcePath) defer func() func() { _cgo0 := /*line :185:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :185:36*/_Cfunc_free(_cgo0); }}()() c := func() *_Ctype_struct__GdkPixbuf{ var _cgo0 *_Ctype_char = /*line :187:38*/(*_Ctype_gchar /*line :187:47*/)(cstr); _cgoBase1 := /*line :187:56*/&gerr; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :187:62*/_Cfunc_gdk_pixbuf_new_from_resource(_cgo0, _cgo1); }() if gerr != nil { defer func() func() { _cgo0 := /*line :190:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :190:29*/_Cfunc_g_error_free(_cgo0); }}()() return nil, errors.New(( /*line :191:26*/_Cfunc_GoString /*line :191:35*/)(gerr.message)) } obj := glib.Take(unsafe.Pointer(c)) return &Pixbuf{obj}, nil } // PixbufNewFromResourceAtScale is a wrapper around gdk_pixbuf_new_from_resource_at_scale() func PixbufNewFromResourceAtScale(resourcePath string, width, height int, preserveAspectRatio bool) (*Pixbuf, error) { var gerr * /*line :200:12*/_Ctype_GError /*line :200:20*/ cstr := ( /*line :202:10*/_Cfunc_CString /*line :202:18*/)(resourcePath) defer func() func() { _cgo0 := /*line :203:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :203:36*/_Cfunc_free(_cgo0); }}()() cPreserveAspectRatio := gbool(preserveAspectRatio) c := func() *_Ctype_struct__GdkPixbuf{ var _cgo0 *_Ctype_char = /*line :208:3*/(*_Ctype_gchar /*line :208:12*/)(cstr); var _cgo1 _Ctype_int = _Ctype_gint /*line :209:9*/(width); var _cgo2 _Ctype_int = _Ctype_gint /*line :210:9*/(height); var _cgo3 _Ctype_gboolean = _Ctype_gboolean /*line :211:13*/(cPreserveAspectRatio); _cgoBase4 := /*line :212:3*/&gerr; _cgo4 := _cgoBase4; _cgoCheckPointer(_cgoBase4, 0 == 0); return /*line :213:3*/_Cfunc_gdk_pixbuf_new_from_resource_at_scale(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4); }() if gerr != nil { defer func() func() { _cgo0 := /*line :216:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :216:29*/_Cfunc_g_error_free(_cgo0); }}()() return nil, errors.New(( /*line :217:26*/_Cfunc_GoString /*line :217:35*/)(gerr.message)) } obj := glib.Take(unsafe.Pointer(c)) return &Pixbuf{obj}, nil } // TODO: // gdk_pixbuf_new_from_xpm_data(). // gdk_pixbuf_new_subpixbuf() // PixbufCopy is a wrapper around gdk_pixbuf_copy(). func PixbufCopy(v *Pixbuf) (*Pixbuf, error) { c := func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :230:25*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :230:36*/_Cfunc_gdk_pixbuf_copy(_cgo0); }() if c == nil { return nil, nilPtrErr } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} //obj.Ref() runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // The GdkPixbuf Structure // GetColorspace is a wrapper around gdk_pixbuf_get_colorspace(). func (v *Pixbuf) GetColorspace() Colorspace { c := func() _Ctype_GdkColorspace{ _cgo0 := /*line :246:35*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :246:46*/_Cfunc_gdk_pixbuf_get_colorspace(_cgo0); }() return Colorspace(c) } // GetNChannels is a wrapper around gdk_pixbuf_get_n_channels(). func (v *Pixbuf) GetNChannels() int { c := func() _Ctype_int{ _cgo0 := /*line :252:35*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :252:46*/_Cfunc_gdk_pixbuf_get_n_channels(_cgo0); }() return int(c) } // GetHasAlpha is a wrapper around gdk_pixbuf_get_has_alpha(). func (v *Pixbuf) GetHasAlpha() bool { c := func() _Ctype_gboolean{ _cgo0 := /*line :258:34*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :258:45*/_Cfunc_gdk_pixbuf_get_has_alpha(_cgo0); }() return gobool(c) } // GetBitsPerSample is a wrapper around gdk_pixbuf_get_bits_per_sample(). func (v *Pixbuf) GetBitsPerSample() int { c := func() _Ctype_int{ _cgo0 := /*line :264:40*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :264:51*/_Cfunc_gdk_pixbuf_get_bits_per_sample(_cgo0); }() return int(c) } // GetPixels is a wrapper around gdk_pixbuf_get_pixels_with_length(). // A Go slice is used to represent the underlying Pixbuf data array, one // byte per channel. func (v *Pixbuf) GetPixels() (channels []byte) { var length /*line :272:13*/_Ctype_guint /*line :272:20*/ c := func() *_Ctype_guchar{ _cgo0 := /*line :273:43*/v.native(); var _cgo1 *_Ctype_guint = /*line :273:55*/&length; _cgoCheckPointer(_cgo0, nil); return /*line :273:63*/_Cfunc_gdk_pixbuf_get_pixels_with_length(_cgo0, _cgo1); }() sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&channels)) sliceHeader.Data = uintptr(unsafe.Pointer(c)) sliceHeader.Len = int(length) sliceHeader.Cap = int(length) // To make sure the slice doesn't outlive the Pixbuf, add a reference v.Ref() runtime.SetFinalizer(&channels, func(_ *[]byte) { glib.FinalizerStrategy(v.Unref) }) return } // GetWidth is a wrapper around gdk_pixbuf_get_width(). func (v *Pixbuf) GetWidth() int { c := func() _Ctype_int{ _cgo0 := /*line :289:30*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :289:41*/_Cfunc_gdk_pixbuf_get_width(_cgo0); }() return int(c) } // GetHeight is a wrapper around gdk_pixbuf_get_height(). func (v *Pixbuf) GetHeight() int { c := func() _Ctype_int{ _cgo0 := /*line :295:31*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :295:42*/_Cfunc_gdk_pixbuf_get_height(_cgo0); }() return int(c) } // GetRowstride is a wrapper around gdk_pixbuf_get_rowstride(). func (v *Pixbuf) GetRowstride() int { c := func() _Ctype_int{ _cgo0 := /*line :301:34*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :301:45*/_Cfunc_gdk_pixbuf_get_rowstride(_cgo0); }() return int(c) } // GetOption is a wrapper around gdk_pixbuf_get_option(). ok is true if // the key has an associated value. func (v *Pixbuf) GetOption(key string) (value string, ok bool) { cstr := ( /*line :308:10*/_Cfunc_CString /*line :308:18*/)(key) defer func() func() { _cgo0 := /*line :309:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :309:36*/_Cfunc_free(_cgo0); }}()() c := func() *_Ctype_gchar{ _cgo0 := /*line :310:31*/v.native(); var _cgo1 *_Ctype_gchar = /*line :310:43*/(*_Ctype_gchar /*line :310:52*/)(cstr); _cgoCheckPointer(_cgo0, nil); return /*line :310:60*/_Cfunc_gdk_pixbuf_get_option(_cgo0, _cgo1); }() if c == nil { return "", false } return ( /*line :314:9*/_Cfunc_GoString /*line :314:18*/)((* /*line :314:22*/_Ctype_char /*line :314:28*/)(c)), true } // Scaling // ScaleSimple is a wrapper around gdk_pixbuf_scale_simple(). func (v *Pixbuf) ScaleSimple(destWidth, destHeight int, interpType InterpType) (*Pixbuf, error) { c := func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :321:33*/v.native(); var _cgo1 _Ctype_int = _Ctype_int /*line :321:50*/(destWidth); var _cgo2 _Ctype_int = _Ctype_int /*line :322:8*/(destHeight); var _cgo3 _Ctype_GdkInterpType = _Ctype_GdkInterpType /*line :322:37*/(interpType); _cgoCheckPointer(_cgo0, nil); return /*line :322:50*/_Cfunc_gdk_pixbuf_scale_simple(_cgo0, _cgo1, _cgo2, _cgo3); }() if c == nil { return nil, nilPtrErr } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} //obj.Ref() runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // Scale is a wrapper around gdk_pixbuf_scale(). func (v *Pixbuf) Scale(dest *Pixbuf, destX, destY, destWidth, destHeight int, offsetX, offsetY, scaleX, scaleY float64, interpType InterpType) { func() { _cgo0 := /*line :337:3*/v.native(); _cgo1 := /*line :338:3*/dest.native(); var _cgo2 _Ctype_int = _Ctype_int /*line :339:8*/(destX); var _cgo3 _Ctype_int = _Ctype_int /*line :340:8*/(destY); var _cgo4 _Ctype_int = _Ctype_int /*line :341:8*/(destWidth); var _cgo5 _Ctype_int = _Ctype_int /*line :342:8*/(destHeight); var _cgo6 _Ctype_double = _Ctype_double /*line :343:11*/(offsetX); var _cgo7 _Ctype_double = _Ctype_double /*line :344:11*/(offsetY); var _cgo8 _Ctype_double = _Ctype_double /*line :345:11*/(scaleX); var _cgo9 _Ctype_double = _Ctype_double /*line :346:11*/(scaleY); var _cgo10 _Ctype_GdkInterpType = _Ctype_GdkInterpType /*line :347:18*/(interpType); _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); /*line :348:3*/_Cfunc_gdk_pixbuf_scale(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4, _cgo5, _cgo6, _cgo7, _cgo8, _cgo9, _cgo10); }() } // Composite is a wrapper around gdk_pixbuf_composite(). func (v *Pixbuf) Composite(dest *Pixbuf, destX, destY, destWidth, destHeight int, offsetX, offsetY, scaleX, scaleY float64, interpType InterpType, overallAlpha int) { func() { _cgo0 := /*line :354:3*/v.native(); _cgo1 := /*line :355:3*/dest.native(); var _cgo2 _Ctype_int = _Ctype_int /*line :356:8*/(destX); var _cgo3 _Ctype_int = _Ctype_int /*line :357:8*/(destY); var _cgo4 _Ctype_int = _Ctype_int /*line :358:8*/(destWidth); var _cgo5 _Ctype_int = _Ctype_int /*line :359:8*/(destHeight); var _cgo6 _Ctype_double = _Ctype_double /*line :360:11*/(offsetX); var _cgo7 _Ctype_double = _Ctype_double /*line :361:11*/(offsetY); var _cgo8 _Ctype_double = _Ctype_double /*line :362:11*/(scaleX); var _cgo9 _Ctype_double = _Ctype_double /*line :363:11*/(scaleY); var _cgo10 _Ctype_GdkInterpType = _Ctype_GdkInterpType /*line :364:18*/(interpType); var _cgo11 _Ctype_int = _Ctype_int /*line :365:8*/(overallAlpha); _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); /*line :366:3*/_Cfunc_gdk_pixbuf_composite(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4, _cgo5, _cgo6, _cgo7, _cgo8, _cgo9, _cgo10, _cgo11); }() } // TODO: // gdk_pixbuf_composite_color_simple(). // gdk_pixbuf_composite_color(). // Utilities // TODO: // gdk_pixbuf_copy_area(). // gdk_pixbuf_saturate_and_pixelate(). // Fill is a wrapper around gdk_pixbuf_fill(). The given pixel is an RGBA value. func (v *Pixbuf) Fill(pixel uint32) { func() { _cgo0 := /*line :381:20*/v.native(); var _cgo1 _Ctype_guint32 = _Ctype_guint32 /*line :381:41*/(pixel); _cgoCheckPointer(_cgo0, nil); /*line :381:49*/_Cfunc_gdk_pixbuf_fill(_cgo0, _cgo1); }() } // AddAlpha is a wrapper around gdk_pixbuf_add_alpha(). If substituteColor is // true, then the color specified by r, g and b will be assigned zero opacity. func (v *Pixbuf) AddAlpha(substituteColor bool, r, g, b uint8) *Pixbuf { c := func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :387:30*/v.native(); var _cgo1 _Ctype_gboolean = /*line :387:42*/gbool(substituteColor); var _cgo2 _Ctype_guchar = _Ctype_guchar /*line :387:74*/(r); var _cgo3 _Ctype_guchar = _Ctype_guchar /*line :387:87*/(g); var _cgo4 _Ctype_guchar = _Ctype_guchar /*line :387:100*/(b); _cgoCheckPointer(_cgo0, nil); return /*line :387:104*/_Cfunc_gdk_pixbuf_add_alpha(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4); }() obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p } // File saving // TODO: // gdk_pixbuf_savev(). // gdk_pixbuf_save(). // SaveJPEG is a convenience wrapper around gdk_pixbuf_save() for saving image as jpeg file. // Quality is a number between 0...100 func (v *Pixbuf) SaveJPEG(path string, quality int) error { cpath := ( /*line :405:11*/_Cfunc_CString /*line :405:19*/)(path) cquality := ( /*line :406:14*/_Cfunc_CString /*line :406:22*/)(strconv.Itoa(quality)) defer func() func() { _cgo0 := /*line :407:15*/unsafe.Pointer(cpath); return func() { _cgoCheckPointer(_cgo0, nil); /*line :407:37*/_Cfunc_free(_cgo0); }}()() defer func() func() { _cgo0 := /*line :408:15*/unsafe.Pointer(cquality); return func() { _cgoCheckPointer(_cgo0, nil); /*line :408:40*/_Cfunc_free(_cgo0); }}()() var err * /*line :410:11*/_Ctype_GError /*line :410:19*/ c := func() _Ctype_gboolean{ _cgo0 := /*line :411:31*/v.native(); var _cgo1 *_Ctype_char = /*line :411:43*/cpath; _cgoBase2 := /*line :411:50*/&err; _cgo2 := _cgoBase2; var _cgo3 *_Ctype_char = /*line :411:56*/cquality; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :411:65*/_Cfunc__gdk_pixbuf_save_jpeg(_cgo0, _cgo1, _cgo2, _cgo3); }() if !gobool(c) { defer func() func() { _cgo0 := /*line :413:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :413:28*/_Cfunc_g_error_free(_cgo0); }}()() return errors.New(( /*line :414:21*/_Cfunc_GoString /*line :414:30*/)((* /*line :414:34*/_Ctype_char /*line :414:40*/)(err.message))) } return nil } // SavePNG is a convenience wrapper around gdk_pixbuf_save() for saving image as png file. // Compression is a number between 0...9 func (v *Pixbuf) SavePNG(path string, compression int) error { cpath := ( /*line :423:11*/_Cfunc_CString /*line :423:19*/)(path) ccompression := ( /*line :424:18*/_Cfunc_CString /*line :424:26*/)(strconv.Itoa(compression)) defer func() func() { _cgo0 := /*line :425:15*/unsafe.Pointer(cpath); return func() { _cgoCheckPointer(_cgo0, nil); /*line :425:37*/_Cfunc_free(_cgo0); }}()() defer func() func() { _cgo0 := /*line :426:15*/unsafe.Pointer(ccompression); return func() { _cgoCheckPointer(_cgo0, nil); /*line :426:44*/_Cfunc_free(_cgo0); }}()() var err * /*line :428:11*/_Ctype_GError /*line :428:19*/ c := func() _Ctype_gboolean{ _cgo0 := /*line :429:30*/v.native(); var _cgo1 *_Ctype_char = /*line :429:42*/cpath; _cgoBase2 := /*line :429:49*/&err; _cgo2 := _cgoBase2; var _cgo3 *_Ctype_char = /*line :429:55*/ccompression; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :429:68*/_Cfunc__gdk_pixbuf_save_png(_cgo0, _cgo1, _cgo2, _cgo3); }() if !gobool(c) { defer func() func() { _cgo0 := /*line :431:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :431:28*/_Cfunc_g_error_free(_cgo0); }}()() return errors.New(( /*line :432:21*/_Cfunc_GoString /*line :432:30*/)((* /*line :432:34*/_Ctype_char /*line :432:40*/)(err.message))) } return nil } /* * PixbufFormat */ type PixbufFormat struct { format * /*line :442:10*/_Ctype_GdkPixbufFormat /*line :442:27*/ } // native returns a pointer to the underlying GdkPixbuf. func (v *PixbufFormat) native() * /*line :446:34*/_Ctype_GdkPixbufFormat /*line :446:51*/ { if v == nil { return nil } return v.format } func wrapPixbufFormat(obj * /*line :454:28*/_Ctype_GdkPixbufFormat /*line :454:45*/) *PixbufFormat { return &PixbufFormat{obj} } // Native returns a pointer to the underlying GdkPixbuf. func (v *PixbufFormat) Native() uintptr { return uintptr(unsafe.Pointer(v.native())) } /* * GdkPixbufAnimation */ // PixbufAnimation is a representation of GDK's GdkPixbufAnimation. type PixbufAnimation struct { *glib.Object } // native returns a pointer to the underlying GdkPixbufAnimation. func (v *PixbufAnimation) native() * /*line :473:37*/_Ctype_GdkPixbufAnimation /*line :473:57*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GdkPixbufAnimation{ _cgo0 := /*line :478:32*/p; _cgoCheckPointer(_cgo0, nil); return /*line :478:34*/_Cfunc_toGdkPixbufAnimation(_cgo0); }() } func (v *PixbufAnimation) NativePrivate() * /*line :481:44*/_Ctype_GdkPixbufAnimation /*line :481:64*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GdkPixbufAnimation{ _cgo0 := /*line :486:32*/p; _cgoCheckPointer(_cgo0, nil); return /*line :486:34*/_Cfunc_toGdkPixbufAnimation(_cgo0); }() } func (v *PixbufAnimation) GetStaticImage() *Pixbuf { c := func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :490:47*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :490:58*/_Cfunc_gdk_pixbuf_animation_get_static_image(_cgo0); }() obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &Pixbuf{obj} // Add a reference so the pixbuf doesn't outlive the parent pixbuf // animation. v.Ref() runtime.SetFinalizer(p, func(*Pixbuf) { glib.FinalizerStrategy(v.Unref) }) return p } func marshalPixbufAnimation(p uintptr) (interface{}, error) { c := ( /*line :503:7*/_Cfunc_g_value_get_object /*line :503:26*/)((* /*line :503:30*/_Ctype_GValue /*line :503:38*/)(unsafe.Pointer(p))) obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} return &PixbufAnimation{obj}, nil } // PixbufAnimationNewFromFile is a wrapper around gdk_pixbuf_animation_new_from_file(). func PixbufAnimationNewFromFile(filename string) (*PixbufAnimation, error) { cstr := ( /*line :510:10*/_Cfunc_CString /*line :510:18*/)(filename) defer func() func() { _cgo0 := /*line :511:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :511:36*/_Cfunc_free(_cgo0); }}()() var err * /*line :513:11*/_Ctype_GError /*line :513:19*/ c := func() *_Ctype_struct__GdkPixbufAnimation{ var _cgo0 *_Ctype_char = /*line :514:44*/(*_Ctype_char /*line :514:52*/)(cstr); _cgoBase1 := /*line :514:61*/&err; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :514:66*/_Cfunc_gdk_pixbuf_animation_new_from_file(_cgo0, _cgo1); }() if c == nil { defer func() func() { _cgo0 := /*line :516:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :516:28*/_Cfunc_g_error_free(_cgo0); }}()() return nil, errors.New(( /*line :517:26*/_Cfunc_GoString /*line :517:35*/)((* /*line :517:39*/_Ctype_char /*line :517:45*/)(err.message))) } obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} p := &PixbufAnimation{obj} runtime.SetFinalizer(p, func(_ interface{}) { glib.FinalizerStrategy(obj.Unref) }) return p, nil } // TODO: // gdk_pixbuf_animation_new_from_resource(). /* * GdkPixbufLoader */ // PixbufLoader is a representation of GDK's GdkPixbufLoader. // Users of PixbufLoader are expected to call Close() when they are finished. type PixbufLoader struct { *glib.Object } // native() returns a pointer to the underlying GdkPixbufLoader. func (v *PixbufLoader) native() * /*line :540:34*/_Ctype_GdkPixbufLoader /*line :540:51*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GdkPixbufLoader{ _cgo0 := /*line :545:29*/p; _cgoCheckPointer(_cgo0, nil); return /*line :545:31*/_Cfunc_toGdkPixbufLoader(_cgo0); }() } func marshalPixbufLoader(p uintptr) (interface{}, error) { c := ( /*line :549:7*/_Cfunc_g_value_get_object /*line :549:26*/)((* /*line :549:30*/_Ctype_GValue /*line :549:38*/)(unsafe.Pointer(p))) obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} return &PixbufLoader{obj}, nil } // PixbufLoaderNew() is a wrapper around gdk_pixbuf_loader_new(). func PixbufLoaderNew() (*PixbufLoader, error) { c := ( /*line :556:7*/_Cfunc_gdk_pixbuf_loader_new /*line :556:29*/)() if c == nil { return nil, nilPtrErr } return &PixbufLoader{glib.AssumeOwnership(unsafe.Pointer(c))}, nil } // PixbufLoaderNewWithType() is a wrapper around gdk_pixbuf_loader_new_with_type(). func PixbufLoaderNewWithType(t string) (*PixbufLoader, error) { var err * /*line :565:11*/_Ctype_GError /*line :565:19*/ cstr := ( /*line :567:10*/_Cfunc_CString /*line :567:18*/)(t) defer func() func() { _cgo0 := /*line :568:15*/unsafe.Pointer(cstr); return func() { _cgoCheckPointer(_cgo0, nil); /*line :568:36*/_Cfunc_free(_cgo0); }}()() c := func() *_Ctype_struct__GdkPixbufLoader{ var _cgo0 *_Ctype_char = /*line :570:41*/(*_Ctype_char /*line :570:49*/)(cstr); _cgoBase1 := /*line :570:58*/&err; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :570:63*/_Cfunc_gdk_pixbuf_loader_new_with_type(_cgo0, _cgo1); }() if err != nil { defer func() func() { _cgo0 := /*line :572:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :572:28*/_Cfunc_g_error_free(_cgo0); }}()() return nil, errors.New(( /*line :573:26*/_Cfunc_GoString /*line :573:35*/)((* /*line :573:39*/_Ctype_char /*line :573:45*/)(err.message))) } if c == nil { return nil, nilPtrErr } return &PixbufLoader{glib.AssumeOwnership(unsafe.Pointer(c))}, nil } // Write() is a wrapper around gdk_pixbuf_loader_write(). The // function signature differs from the C equivalent to satisify the // io.Writer interface. func (v *PixbufLoader) Write(data []byte) (int, 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 err * /*line :596:11*/_Ctype_GError /*line :596:19*/ c := func() _Ctype_gboolean{ _cgo0 := /*line :597:33*/v.native(); var _cgo1 *_Ctype_guchar = /*line :598:3*/(*_Ctype_guchar /*line :598:13*/)(unsafe.Pointer(&data[0])); var _cgo2 _Ctype_gsize = _Ctype_gsize /*line :598:49*/(len(data)); _cgoBase3 := /*line :599:3*/&err; _cgo3 := _cgoBase3; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase3, 0 == 0); return /*line :599:8*/_Cfunc_gdk_pixbuf_loader_write(_cgo0, _cgo1, _cgo2, _cgo3); }() if !gobool(c) { defer func() func() { _cgo0 := /*line :602:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :602:28*/_Cfunc_g_error_free(_cgo0); }}()() return 0, errors.New(( /*line :603:24*/_Cfunc_GoString /*line :603:33*/)((* /*line :603:37*/_Ctype_char /*line :603:43*/)(err.message))) } return len(data), nil } // Convenient function like above for Pixbuf. Write data, close loader and return Pixbuf. func (v *PixbufLoader) WriteAndReturnPixbuf(data []byte) (*Pixbuf, error) { _, err := v.Write(data) if err != nil { return nil, err } if err := v.Close(); err != nil { return nil, err } return v.GetPixbuf() } // Close is a wrapper around gdk_pixbuf_loader_close(). An error is // returned instead of a bool like the native C function to support the // io.Closer interface. func (v *PixbufLoader) Close() error { var err * /*line :627:11*/_Ctype_GError /*line :627:19*/ if ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :629:44*/v.native(); _cgoBase1 := /*line :629:56*/&err; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :629:61*/_Cfunc_gdk_pixbuf_loader_close(_cgo0, _cgo1); }()); !ok { defer func() func() { _cgo0 := /*line :630:24*/err; return func() { _cgoCheckPointer(_cgo0, nil); /*line :630:28*/_Cfunc_g_error_free(_cgo0); }}()() return errors.New(( /*line :631:21*/_Cfunc_GoString /*line :631:30*/)((* /*line :631:34*/_Ctype_char /*line :631:40*/)(err.message))) } return nil } // GetPixbuf is a wrapper around gdk_pixbuf_loader_get_pixbuf(). func (v *PixbufLoader) GetPixbuf() (*Pixbuf, error) { c := func() *_Ctype_struct__GdkPixbuf{ _cgo0 := /*line :638:38*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :638:49*/_Cfunc_gdk_pixbuf_loader_get_pixbuf(_cgo0); }() if c == nil { return nil, nilPtrErr } return &Pixbuf{glib.Take(unsafe.Pointer(c))}, nil } // GetAnimation is a wrapper around gdk_pixbuf_loader_get_animation(). func (v *PixbufLoader) GetAnimation() (*PixbufAnimation, error) { c := func() *_Ctype_struct__GdkPixbufAnimation{ _cgo0 := /*line :648:41*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :648:52*/_Cfunc_gdk_pixbuf_loader_get_animation(_cgo0); }() if c == nil { return nil, nilPtrErr } return &PixbufAnimation{glib.Take(unsafe.Pointer(c))}, nil } // Convenient function like above for Pixbuf. Write data, close loader and return PixbufAnimation. func (v *PixbufLoader) WriteAndReturnPixbufAnimation(data []byte) (*PixbufAnimation, error) { _, err := v.Write(data) if err != nil { return nil, err } if err := v.Close(); err != nil { return nil, err } return v.GetAnimation() }