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)
| 229 | // http://qt-project.org/doc/qt-5.0/qtquick/qquickimageprovider.html |
| 230 | // |
| 231 | func (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 |
| 245 | func hookRequestImage(imageFunc unsafe.Pointer, cid *C.char, cidLen, cwidth, cheight C.int) unsafe.Pointer { |
no test coverage detected