JavaScript对象的js-ctypes [英] js-ctypes from javascript objects

查看:150
本文介绍了JavaScript对象的js-ctypes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Firefox扩展,它接收二进制图像作为 uint8_t 阵列缓冲区

我的扩展我加载一个.dll文件,有一个功能,我需要使用该接收到的图像。该函数接受一个 ctype.uint8_t.ptr 参数并返回一个 ctype.uint8_t.ptr 值。

似乎无法找到将 ArrayBuffer 转换为此特定ctype的方法,以便我可以将它传递给该函数。有没有一个正确的方法来做到这一点?



使用ImplicitConvert()给出错误:参数必须是非负整数

解决方案

您应该可以做到:

  var a = new Uint8Array(1 << 10); 
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆