ANE、iOS 和 BitmapData
是否有将位图数据传递到 iOS 并返回修改后的副本的示例。我正在尝试将位图转换为 jpeg - 类似于 Windows 中的此示例 http://blog.magicalhobo.com/2011/09/12/air-3-native-extension-imageprocessor/ 但每次都会崩溃。
我很确定我在做一些基本的错误,但不是一个 iOS / Objective C 程序员我真的只是在尝试魔法咒语,我找不到任何好的例子。有什么帮助吗?
肖恩
P.S.以下是我的尝试:
FREObject encodeJPEG(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject objectBitmapData = argv[0];
FREBitmapData bitmapData;
FREAcquireBitmapData(objectBitmapData, &bitmapData);
int width = bitmapData.width;
int height = bitmapData.height;
int stride = bitmapData.lineStride32 * 4;
uint32_t* input = bitmapData.bits32;
FREReleaseBitmapData(objectBitmapData);
UIImage *myImage = [UIImage imageWithData:input];
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9);
FREObject objectByteArray = argv[1];
FREByteArray byteArray;
FREObject length;
FRENewObjectFromUint32(jpgData.length, &length);
FRESetObjectProperty(objectByteArray, (const uint8_t*) "length", length, NULL);
FREAcquireByteArray(objectByteArray, &byteArray);
memcpy(byteArray.bytes, jpgData.bytes, jpgData.length);
FREReleaseByteArray(objectByteArray);
return NULL;
}
Is there any example of passing bitmap data into iOS and returning a modfified copy. I am trying to convert a bitmap into jpeg - similar to this example in Windows http://blog.magicalhobo.com/2011/09/12/air-3-native-extension-imagepro cessor/ but it crashed every time.
I am pretty sure I am doing something basic wrong but not been an iOS / Objective C programmer I am really just trying magic incantations and I can't find any good examples. Any help appreciated?
Sean
P.S. Below is my attempt:
FREObject encodeJPEG(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject objectBitmapData = argv[0];
FREBitmapData bitmapData;
FREAcquireBitmapData(objectBitmapData, &bitmapData);
int width = bitmapData.width;
int height = bitmapData.height;
int stride = bitmapData.lineStride32 * 4;
uint32_t* input = bitmapData.bits32;
FREReleaseBitmapData(objectBitmapData);
UIImage *myImage = [UIImage imageWithData:input];
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9);
FREObject objectByteArray = argv[1];
FREByteArray byteArray;
FREObject length;
FRENewObjectFromUint32(jpgData.length, &length);
FRESetObjectProperty(objectByteArray, (const uint8_t*) "length", length, NULL);
FREAcquireByteArray(objectByteArray, &byteArray);
memcpy(byteArray.bytes, jpgData.bytes, jpgData.length);
FREReleaseByteArray(objectByteArray);
return NULL;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最终版本 - 似乎工作正常 - 编码正常,我认为在其自身之后清理正常。
肖恩
}
Finale version - seems to work ok - encodes ok and I think cleans up after itself ok.
Sean
}
这有点有效,除了 jpeg 中的红色是蓝色,并且不确定我是否发布了一切正常。
这就是明天的战斗。
肖恩
This kinda works except reds are blues in jpeg and not sure I am releasing everything ok.
Thats tomorrows battle.
Sean
交换红色和蓝色像素的位置,
您从 iOS 获得的格式是:
0xAARRGGBB
预计在 AIR 应用程序上显示的是:
0xAABBGGRR
Exchange the position of Red and Blue Pixels
the format you get from iOS is :
0xAARRGGBB
and the one expected to show on an AIR app is :
0xAABBGGRR