c/c++语言开发共享从C返回的ByteArray格式无效

以下是代码段:

AS方:( img引用实例)

  bitmapData = Bitmap(img.content).bitmapData; var pixels:ByteArray = bitmapData.getPixels(bitmapData.rect); pixels.position = 0; var output:ByteArray = new ByteArray(); img_width = bitmapData.width; img_height = bitmapData.height; ////invoke C code by alchemy lomoEncoder.encode(pixels, output, img_width, img_height); var newImage:Image = new Image(); //can't show the image newImage.source = output; 

C代码:

 AS3_Val dest; AS3_Val source; unsigned char* pixels = (unsigned char *)malloc(Size); AS3_ByteArray_readBytes(pixels, source, Size); pixels = darkCornerLomoEffect((unsigned char*)pixels, image_width, image_height); AS3_ByteArray_writeBytes(dest, (char*) pixels, length); 

在AS端,当从C获取dest时,loader.load(dest)抛出一个错误:Unhandled IOErrorEvent:。 text =错误#2124。 那么如何处理byteArray格式,那么AS端可以重新组织并将其用作Image源属性吗?

如果您有一个bytearray并且想要加载图像源,则可以执行以下操作:

 var b:ByteArray = new ByteArray(); var f:BitmapData = new BitmapData(100, 100); f.setPixels(new Rectangle(0, 0, 100, 100), b); 

请问您能提供AS3代码片段吗?

我怀疑你的问题是字节顺序 。 从输入ByteArray读取后,您需要翻转字节。 对于输出ByteArray,您需要再次翻转它们,或将其endian属性设置为Endian.LITTLE_ENDIAN

以上就是c/c++开发分享从C返回的ByteArray格式无效相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/549405.html

(0)
上一篇 2021年1月14日
下一篇 2021年1月14日

精彩推荐