Beispiel #1
0
func (c *Camera) Init() int {
	c.context = C.gp_context_new()

	C.gp_camera_new(&c.camera)
	err := C.gp_camera_init(c.camera, c.context)
	return int(err)
}
Beispiel #2
0
//GetNewGPhotoCamera returns a new camera instance
func GetNewGPhotoCamera(context *Context) (*Camera, error) {
	var gpCamera *C.Camera
	C.gp_camera_new((**C.Camera)(unsafe.Pointer(&gpCamera)))

	if gpCamera == nil {
		return nil, fmt.Errorf("Cannot initialize camera pointer")
	}

	initCode := C.gp_camera_init(gpCamera, context.gpContext)
	if initCode != gpOk {
		C.gp_camera_exit(gpCamera, context.gpContext)
		C.gp_camera_unref(gpCamera)
		return nil, fmt.Errorf("Error number : %d", initCode)
	}
	return &Camera{
		gpCamera:  gpCamera,
		gpContext: context.gpContext,
	}, nil
}