gpt4 book ai didi

c - 从 C 返回的 ByteArray 格式无效

转载 作者:行者123 更新时间:2023-11-30 14:25:33 24 4
gpt4 key购买 nike

以下是代码片段:

AS 端:(img 引用 <Image> 实例)

        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端,当得到dest时从 C 开始,loader.load(dest) 抛出错误:Unhandled IOErrorEvent:。文本=错误#2124。那么如何处理byteArray格式,以便AS端可以重新组织并使用它作为Image来源属性(property)?

最佳答案

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

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

请提供您的 AS3 代码片段吗?

关于c - 从 C 返回的 ByteArray 格式无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10210240/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com