问题描述
我正在开发一个Firefox扩展,它接收二进制图像作为 uint8_t 的阵列缓冲区。
我的扩展我加载一个.dll文件,有一个功能,我需要使用该接收到的图像。该函数接受一个 ctype.uint8_t.ptr 参数并返回一个 ctype.uint8_t.ptr 值。
似乎无法找到将 ArrayBuffer 转换为此特定ctype的方法,以便我可以将它传递给该函数。有没有一个正确的方法来做到这一点?
使用ImplicitConvert()给出错误:参数必须是非负整数。
您应该可以做到:
var a = new Uint8Array(1 var ptr = new ctypes.uint8_t.ptr(a.buffer);
这个东西似乎没有记录,但有一个,证明了这一点。 b $ b
I'm working on a Firefox extension that receives binary images as ArrayBuffers of uint8_t.
In my extension I load a .dll file that has a function that I need to use on that received image. The function takes a ctype.uint8_t.ptr parameter and returns a ctype.uint8_t.ptr value.
I can't seem to find a way of converting the ArrayBuffer to this particular ctype so that I can pass it along to the function. Is there a correct way to do this?
Using ImplicitConvert() gives an Error: argument must be a nonnegative integer.
You should be able to do just:
var a = new Uint8Array(1<<10);
var ptr = new ctypes.uint8_t.ptr(a.buffer);
The stuff is not documented it seems, but there are some tests that demonstrate this.
这篇关于JavaScript对象的js-ctypes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!