问题描述
以下是code片断:
AS方:(IMG是引用一个<图像>
实例)
AS side:(img is reference to an <Image>
instance)
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 code:
C code:
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端,当获得 DEST
从C,loader.load(DEST)抛出一个错误:未处理IOErrorEvent :.文本=错误#2124。因此,如何处理的字节数组格式,这样方可以重新组织,并以此为图片
源属性?
In the AS side, when get the dest
from C, loader.load(dest) throw an error:Unhandled IOErrorEvent:. text=Error #2124.So How to deal with the byteArray format, so AS side can reorganize and use it as Image
source property?
推荐答案
我怀疑你的问题是byte-ordering.你需要从输入的ByteArray看完后翻转你的字节。对于输出的ByteArray您可能需要再次翻转它们,或者将其端
属性 Endian.LITTLE_ENDIAN
。
I suspect your problem is byte-ordering. You need to flip your bytes after reading from the input ByteArray. For the output ByteArray you either need to flip them again, or set its endian
property to Endian.LITTLE_ENDIAN
.
这篇关于ByteArray中的格式返回从C无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!