following is code snippet:
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:
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);
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?