Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 将byteArray与getPixel(no';s';)一起使用,然后设置像素_Actionscript 3_Bytearray_Getpixel - Fatal编程技术网

Actionscript 3 将byteArray与getPixel(no';s';)一起使用,然后设置像素

Actionscript 3 将byteArray与getPixel(no';s';)一起使用,然后设置像素,actionscript-3,bytearray,getpixel,Actionscript 3,Bytearray,Getpixel,以下是我试图做的: one byteArray(colorsByteArray)保存颜色值,这是我用“getPixels”方法创建的 对于屏幕上的每个像素,我都会进行计算,并根据计算得到一个等级,用于检索colorsByteArray中的正确颜色值 最后,我在第二个byteArray(pixelsByteArray)中写入刚刚检索到的颜色。然后我用“setPixels”方法“绘制”这个byteArray 问题是我找不到相同的图像,好像我只是为循环中的每个像素写了一个“setPixel”。我得

以下是我试图做的:

  • one byteArray(colorsByteArray)保存颜色值,这是我用“getPixels”方法创建的
  • 对于屏幕上的每个像素,我都会进行计算,并根据计算得到一个等级,用于检索colorsByteArray中的正确颜色值
  • 最后,我在第二个byteArray(pixelsByteArray)中写入刚刚检索到的颜色。然后我用“setPixels”方法“绘制”这个byteArray
问题是我找不到相同的图像,好像我只是为循环中的每个像素写了一个“setPixel”。我得到的图像在两行中缺少一行,并且水平重复了三次。当然,我猜我一定是在写(或读)我的第二个拜耳里的一些错误,但是有人能解释一下我做错了什么吗?或者,即使我的努力真的有价值:-)因为到目前为止我还没有找到像这样的东西。。。 谢谢

下面是我的一些代码,让事情变得更清楚:

 colorsByteArray = bitmDext.getPixels(new Rectangle(0, 0, myShadeBMD.width, 1));

 canvas.lock();
 for(var i:int = 0; i < STAGE_WIDTH; i++)
 {
     for(var j:int = 0; j < STAGE_HEIGHT; j++)
     {
         //make some calculation on each pixel to get the 'colorRank' uint value

         colorsByteArray.position = colorRank * 4;//unsigned int is 32 bytes, representing 4 slots of a byteArray
         var colorValue:uint = colorsByteArray.readUnsignedInt();

         //canvas.setPixel(i, j, colorValue);//works just fine

         pixelsByteArray.writeUnsignedInt(colorValue);
     }
 }

 pixelsByteArray.position = 0;
 var myRect:Rectangle = new Rectangle(0, 0, STAGE_WIDTH, STAGE_HEIGHT);
 canvas.setPixels(myRect, pixelsByteArray);

 canvas.unlock();
colorsByteArray=bitmDext.getPixels(新矩形(0,0,myShadeBMD.width,1));
canvas.lock();
对于(变量i:int=0;i
添加了可能有帮助的图片:
预期的部分在右边,错误的部分在左边。

看起来像是你打错了,你得到的是
i
,而不是
j
。这是否也存在于您的代码中,或者您只是在此处键入了错误?您好,是的,这是一个拼写错误,我编辑了它,谢谢您的评论。@puggsoy但拼写错误仅存在于本文中,而不存在于我的代码中;-)所以问题仍然没有解决。你能发布原始图像和结果的截图吗?这将更容易识别出哪里出了问题。@puggsoy是的,我已经这样做了,正在编辑我的帖子;-)预期的部分在右边,错误的部分在左边。