We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hi neil, would you please help to wrap C.stbi_loadf()? I tried to wrap it based on your pkg but failed...
The text was updated successfully, but these errors were encountered:
@leyaocty do you have an example image that you can share to test with?
Sorry, something went wrong.
@neilpa it works now, fyi func Loadf(path string) (dt []float32, w int, h int, nre int, mfree func(), err error) { // C.stbi_set_flip_vertically_on_load(1) // vertical reverse cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath))
var x, y, nr C.int data := C.stbi_loadf(cpath, &x, &y, &nr, 0) if data == nil { msg := C.GoString(C.stbi_failure_reason()) return nil, int(x), int(y), int(nr), nil, errors.New(msg) } var fs []float32 head := (*reflect.SliceHeader)(unsafe.Pointer(&fs)) head.Cap = 1 head.Len = head.Cap head.Data = uintptr(unsafe.Pointer(data)) return fs, int(x), int(y), int(nr), func() { C.stbi_image_free(unsafe.Pointer(data)) }, nil
}
No branches or pull requests
hi neil,
would you please help to wrap C.stbi_loadf()? I tried to wrap it based on your pkg but failed...
The text was updated successfully, but these errors were encountered: