在Javascript中将对象转换为缓冲区(Converting an object to a buffer in Javascript)
我没有使用节点,只是在浏览器中使用简单的Javascript
我需要有效地向网络工作者发送数据。 我已经设法弄清楚如何从数组创建缓冲区:
// assume it contains integers var numbers = new Int8Array(10); // works const data = {buffer: numbers.buffer}; worker.postMessage(data, [data.buffer]);
但是我们假设我有一个如下所示的对象:
var myObject = {'in': [0.123,-0,521], 'out' : [1.409]};
我如何将其转换为缓冲区? 我发现了许多类似的问题,但他们似乎使用Node ,我没有使用。
I'm not using node, just plain Javascript in the browser
I need to efficiently send data to webworkers. I've managed to figure out how to create buffers from arrays:
// assume it contains integers var numbers = new Int8Array(10); // works const data = {buffer: numbers.buffer}; worker.postMessage(data, [data.buffer]);
But let's assume I have an object that looks like the following:
var myObject = {'in': [0.123,-0,521], 'out' : [1.409]};
How would I convert that to a buffer? I've found numerous similar questions but they seem to use Node, which i'm not using.
原文:https://stackoverflow.com/questions/44824553
更新时间:2022-07-10 14:07
最满意答案
$config = array( 'source_image' => $upload_path.$image_data['file_name'], 'maintain_ratio' => FALSE, 'width' => 220, 'height' => 150, 'x_axis' => 350, 'y_axis' => 50 ); $this->image_lib->clear(); $this->image_lib->initialize($config); $this->image_lib->crop();
$config = array( 'source_image' => $upload_path.$image_data['file_name'], 'maintain_ratio' => FALSE, 'width' => 220, 'height' => 150, 'x_axis' => 350, 'y_axis' => 50 ); $this->image_lib->clear(); $this->image_lib->initialize($config); $this->image_lib->crop();
For more details Please See Here For More Info Check Here
相关问答
更多-
它看起来像你的目标图像与源图像大小相同。 如果你想旋转90度以上,你的宽度和高度应该交换: WriteableBitmap wb = new WriteableBitmap(destHeight, destWidth); 另外,如果您围绕原始图像的中心旋转,则其一部分会在边界之外结束。 您可以包含一些翻译转换,或者简单地将图像旋转到不同的点: rt.CenterX = rt.CenterY = Math.Min(width / 2, height / 2); 用一张长方形纸试一下,看看为什么这是有道理的 ...
-
您的给定Codeigniter代码是正常的,除了一个逻辑:您正在操作并输出到同一图像文件两次,因此您的输出文件会被最后一次更改原始文件所覆盖。 我相信这是CI的Image_Lib类的限制,因为每个操作都是单独完成的 - 没有办法一次性“调整大小和裁剪”。 您必须在每个操作之间重新初始化Image_Lib类,以确保在上一个操作的输出文件上调用下一个操作。 $img_config = array( 'source_image' => $src, 'new_image' ...
-
也许存在一个错误。 检查错误: if (!$this->image_lib->resize()){ echo $this->image_lib->display_errors(); } 注意:使用gd2作为库(默认值为gd2): $config['image_library'] = 'gd2'; Maybe exists an error. Check for errors: if (!$this->image_lib->resize()){ echo $this->image_lib- ...
-
$config = array( 'source_image' => $upload_path.$image_data['file_name'], 'maintain_ratio' => FALSE, 'width' => 220, 'height' => 150, 'x_axis' => 350, 'y_axis' => 50 ); $this->image_lib->clear(); $this->image_lib->initialize($config); $this->image_lib->cro ...
-
此外,您可以在左上角尝试使用此代码进行硬裁剪 add_image_size( 'custom-size', 220, 220, array( 'left', 'top' ) ); Also, you can try this code for hard crop in left top add_image_size( 'custom-size', 220, 220, array( 'left', 'top' ) );
-
JCrop没有正确裁剪图像(JCrop not cropping image properly)[2023-03-24]
我尝试使用您的代码并遇到了类似的问题。 使用https://rubyplus.com/articles/3951-Cropping-Images-using-jCrop-jQuery-plugin-in-Rails-5教程中的代码为我工作,它应该像下面的标准jQuery一样: var ImageCropper, bind = function(fn, me){ return function(){ return fn.apply(me,arguments); }; }; jQuery(function( ... -
呈现图像裁剪界面(Presenting an image cropping interface)[2024-03-07]
为了记录的缘故 - Cocoa Controls上的现成组件 http://cocoacontrols.com/platforms/ios/controls/imagecropper For record's sake - A ready made component on Cocoa Controls http://cocoacontrols.com/platforms/ios/controls/imagecropper -
Php图像裁剪(Php image cropping)[2023-01-03]
在你的情况下你使用了错误的功能。 imagecopyresampled可以改变图像的大小。 对于作物功能,最佳选择是图像imagecopy 试试改变这个 $result = @imagecopy($cropped, $image, 0, 0, $x1, $y1, $nw, $nh) or die("error imagecopy()"); 功能图像复制手册 In your case you used incorrect function. imagecopyresampled can chang ... -
图像裁剪问题(Image Cropping issue)[2021-07-10]
创建一个UIImage类别并尝试添加它。 @implementation UIImage(Crop) - (UIImage *)crop:(CGRect)cropRect { cropRect = CGRectMake(cropRect.origin.x*self.scale, cropRect.origin.y*self.scale, cropRect.size.width*self.scale, ... -
使用以下设置: {dragCrop:true,multiple:true,movable:true} use following settings: {dragCrop:true, multiple:true, movable:true}