Václav Benes
08/05/2024, 4:09 PM// kotlin
open external class HeifDecoder {
fun decode(file: JsAny): JsArray<JsAny>
}
@JsName("libheif")
external class Libheif {
fun _de265_get_version(): Int
companion object {
@JsName("HeifDecoder")
var heifDecoder: HeifDecoder
}
}
val libheif = Libheif()
println(libheif)
println(libheif._de265_get_version())
println(Libheif.heifDecoder.decode(Blob()))
an Issue is here
// javascript
var HeifDecoder = function() {
this.decoder = null
};
HeifDecoder.prototype.decode = function(buffer) {
if (this.decoder) {
Module.heif_context_free(this.decoder)
}
and i am gettingArtem Kobzar
08/05/2024, 5:42 PMVáclav Benes
08/05/2024, 7:24 PMVáclav Benes
08/06/2024, 8:16 AMawait new Promise((resolve, reject) => {
image.display(imageData, (displayData) => {
if (!displayData) {
return reject(new Error("HEIF processing error"));
}
resolve();
});
});
is this a proper way?
val context = canvas.getContext("2d") as CanvasRenderingContext2D
val imageData = context.createImageData(width, height)
Promise { resolve, reject ->
image?.display(imageData) {
println(it)
// handle error somehow
if (it.toString() == "null") {
return@display reject(ErrorEvent("HEIF processing error"))
}
resolve(it)
}
}
context.putImageData(imageData, START_X, START_Y)
or should I wrap it in js(""). :)Artem Kobzar
08/06/2024, 8:30 AMjs
function call until there is no way to do it without the function.
In the example I've provided, unfortunately there is no way right now to express something like inner
class inside an external declaration, but we are discussing to allow the keyword inside external declarations.