私はnode.js C++プラグインのデモをビルドしようとしています。 node.jsではARGB形式のビットマップを取得しています。これをhtml5キャンバスに渡す必要があります。私はこれを行う最も効率的な方法を見つけようとしています。なぜなら、それは痛いほど遅いからです。node.jsからhtml5 canvasに画像データを転送するにはどうすればいいですか?
現在、私は次のようにします。
--- in node.js ---
- Convert ARGB to RGBA (because ImageData accepts that format)
- Create v8::ArrayBuffer (wrapper over the underlying buffer)
- Create v8::Uint8ClampedArray (wrapper over the array buffer)
- Return an object which has the Uint8ClampedArray, width and height
--- in the browser ---
- Get the result from my function
- Create ImageData instance with the specified width and height
- Loop over all bytes in the Uint8ClampedArray and copy them to the image data
- context.putImageData(image_data, 0, 0);
私はこれを行うために、より最適な方法が存在しなければならないことをかなり確信しています。それは何とかaddinのバッファを生かし続けるのは問題ではありませんが、私は少なくとも画像データへのバッファのバイトごとのコピーを避けたいと思います。
私は、最初のパラメータが上がるにつれてUint8ClampedArrayをとるImageDataコンストラクタを使用しようとすると、なぜわからないのでしょうか。そのような場合、私はちょうど得ています: v8 :: Object :: GetAlignedPointerFromInternalField()。エラー:未Smiと
おかげ