问题标签 [uint8array]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - How do two unequal `Uint8Array`s influence each other when constructed from an `ArrayBuffer`?
I have an ArrayBuffer
, and I want to get two separate Uint8Array
copies from it. I attempt this by using the Uint8Array
constructor on the ArrayBuffer
twice. The constructed array instances do not equal. Yet, when you alter one, it alters the other in the same way. How is this possible, and why would this be the case?
On the other hand, if you construct new Uint8Array
s from the constructed Uint8Array
, they will be functionally separated as one would expect.
javascript - Render 1 pixel from a 3D array in a HTML5 Canvas using putImageData() and an UInt8ClampedArray
I tried my best to render just 1 pixel form a 3D Array in a HTML5 Canvas unsuccessfully.
(I know this has been done before but not with a 3D Array). But converting a 3D array to an Uint8ClampedArray and pushing to an Uint8ClampedArray isn't easy.
HTML5 also doesn't have another way to display a pixel manipulatable image.
Is it correct that putImageData() is for rendering vertical strings of pixels?
Here is my code, the problem is marked with: "WHAT DO I GOTTA DO HERE":
To test it you can use:
typescript - Typescript 从 ArrayBuffer 获取 Int8Array
我正在使用以下代码将文件作为 ArrayBuffer 读取:
我需要将内容作为字节数组获取,但我做不到。如果我尝试以这种方式转换:
我收到此错误:无法将字符串分配给 ArrayBuffer | ArrayLike | 共享数组缓冲区。fileContent 是字符串吗?我认为它应该是一个 ArrayBuffer,因为我使用的是 readAsArrayBuffer。有没有办法从上传的文件中获取字节数组?谢谢
javascript - 如何在 DataView 中使用 UInt8 处理字节顺序?
使用 UInt8 时似乎没有什么可以处理字节顺序。例如,在处理 UInt16 时,您可以设置是小端还是大端:
dataview.setUint16(byteOffset, value [, littleEndian])
对比
dataview.setUint8(byteOffset, value)
我想这是因为字节序处理字节的顺序,如果我一次插入一个字节,那么我需要自己订购它们。
那么我该如何自己处理字节序呢?我正在使用这个规范创建一个 WAVE 文件头:http: //soundfile.sapp.org/doc/WaveFormat/
标题的第一部分是大端的“ChunkID”,我就是这样做的:
标题的第二部分是小端的“ChunkSize” ,这就是我的做法:
现在我想,由于这些块的字节顺序不同,那么我应该在每个块中做一些不同的事情。在这两种情况下我应该做些什么不同的事情?
干杯!
编辑
我在问这个问题,因为我正在创建的 wav 文件无效(根据https://indiehd.com/auxiliary/flac-validator/)。我怀疑这是因为我没有正确处理字节序。这是完整的波形文件:
reactjs - How to use and convert an image file into Uint8Array in react native?
I am working on React-Native-OpenPGP for Encryption and Decryption. I want to take an image from my folder (local image fetch)/ Image url and convert that image into Uint8Array for encryption/Decryption . I am new to react native , Not able to find a better solution . Links can also help. Need a process to give an image path and convert it into Uint8Array.
Moreover also need a solution to convert an image file to binary data for Encryption/Decryption . Is it possible as openpgp provides two ways to do that one is through String and another is through Uint8Array data ?
python - Keras 模型输出是 float32 而不是 uint8 ...尽管数据标签是 uint8
我正在训练一个模型来预测医学图像中的分割。在训练数据中,输入数据的类型为:numpy.float64,ground truth 标签的类型为:numpy.uint8。问题是由于某种原因,我的模型正在生成 numpy.float32 的输出类型。
图像显示: 数据类型示例
型号定义:
在此先感谢您的帮助:)
c - 将自定义长度的 0 位与 uint8_t 数组连接起来
我尝试将一些位与 c 中的 uint8_t 类型的数组连接起来,如下所示:
现在我,e msg=0xabcf123; 我想将 13(位)与 msg i,e 连接起来;
主要问题是消息存储在 char 数组中,因此多位移位操作不起作用。建议一些解决问题的方法??
stdvector - 是否有比 std::copy 成本更低的操作来将 uint8_t* 数据复制到 uint8_t 类型的向量?
最近我写了一个 c++ 代码,我使用了一个来自外部库的函数。这个函数的一个参数的类型是std::vector,但是我的数据在一个名为payload的变量中,它的类型是const uint8_t*。所以我将我的有效负载数据复制到一个带有 std::copy 的向量中,如下所示:
std::vector my_vector; std::copy(有效载荷,有效载荷 + 长度,back_inserter(my_vector));
由于调用了这么多这段代码,我正在寻找一种成本更低的操作来将我的有效负载数据复制到 my_vector 变量中,以便准备我在代码中使用的函数的输入参数。有没有办法达到这个目的?