MCPcopy
hub / github.com/go-qml/qml / AddImageProvider

Method AddImageProvider

qml.go:231–242  ·  view source on GitHub ↗

AddImageProvider registers f to be called when an image is requested by QML code with the specified provider identifier. It is a runtime error to register the same provider identifier multiple times. The imgId provided to f is the requested image source, with the "image:" scheme and provider identi

(prvId string, f func(imgId string, width, height int) image.Image)

Source from the content-addressed store, hash-verified

229// http://qt-project.org/doc/qt-5.0/qtquick/qquickimageprovider.html
230//
231func (e *Engine) AddImageProvider(prvId string, f func(imgId string, width, height int) image.Image) {
232 if _, ok := e.imageProviders[prvId]; ok {
233 panic(fmt.Sprintf("engine already has an image provider with id %q", prvId))
234 }
235 e.imageProviders[prvId] = &f
236 cprvId, cprvIdLen := unsafeStringData(prvId)
237 RunMain(func() {
238 qprvId := C.newString(cprvId, cprvIdLen)
239 defer C.delString(qprvId)
240 C.engineAddImageProvider(e.addr, qprvId, unsafe.Pointer(&f))
241 })
242}
243
244//export hookRequestImage
245func hookRequestImage(imageFunc unsafe.Pointer, cid *C.char, cidLen, cwidth, cheight C.int) unsafe.Pointer {

Callers 2

runFunction · 0.95
qml_test.goFile · 0.80

Calls 2

unsafeStringDataFunction · 0.85
RunMainFunction · 0.85

Tested by

no test coverage detected