ANE, iOS and BitmapData

Is there any example of passing data bitmap in iOS and return a copy of modfified. I'm trying to convert a bitmap to jpeg - similar to this example in Windows http://blog.magicalhobo.com/2011/09/12/air-3-native-extension-imageprocessor/ but it crashed every time. I'm sure that I'm doing wrong something basic but not not an iOS / Objective C programmer, I try really just magical incantations, and I can't find any good examples. Any help is appreciated?

   

Sean

P.S. Here's my attempt:

FREObject encodeJPEG (FREContext ctx, void * funcData, uint32_t argc, argv, FREObject)

{

FREObject objectBitmapData = argv [0];

FREBitmapData bitmapData;

FREAcquireBitmapData (objectBitmapData, & bitmapData);

width = bitmapData.width int;

int height = bitmapData.height;

int stride = bitmapData.lineStride32 * 4;

uint32_t entry = bitmapData.bits32;

FREReleaseBitmapData (objectBitmapData);

UIImage * myImage = [UIImage imageWithData:input];

NSData * jpgData = UIImageJPEGRepresentation (myImage, 0.9);

FREObject objectByteArray = argv [1];

FREByteArray byteArray;

Length of FREObject;

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;

}

Final version - seems to work ok - encodes ok and I think that cleans up after itself ok.

Sean

FREObject encodeJPEG (FREContext ctx, void * funcData, uint32_t argc, argv [] FREObject)

{

FREObject objectBitmapData = argv [0];

FREBitmapData2 bitmapData;

FREAcquireBitmapData2 (objectBitmapData, & bitmapData);

width = bitmapData.width int;

int height = bitmapData.height;

int stride = bitmapData.lineStride32 * 4;

uint32_t entry = bitmapData.bits32;

make the buffer data provider

CGDataProviderRef provider = CGDataProviderCreateWithData (NULL, bitmapData.bits32, (width * height * 4), NULL);

set up for creating CGImage

int bitsPerComponent = 8;

bitsPerPixel int = 32;

int bytesPerRow = 4 * width;

CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();

BitmapInfo CGBitmapInfo;

If (bitmapData.hasAlpha)

{

If (bitmapData.isPremultiplied)

bitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst;

on the other

bitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaFirst;

}

on the other

{

bitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst;

}

RenderingIntent CGColorRenderingIntent = kCGRenderingIntentDefault;

CGImageRef imageRef is CGImageCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);.

do UIImage of CGImage

UIImage * myImage = [UIImage imageWithCGImage:imageRef];

NSData * jpgData = UIImageJPEGRepresentation (myImage, 0.9);

FREReleaseBitmapData (objectBitmapData);

FREObject objectByteArray = argv [1];

FREByteArray byteArray;

Length of FREObject;

FRENewObjectFromUint32 (jpgData.length, & length);

FRESetObjectProperty (objectByteArray, (const uint8_t *) 'length', length, NULL);

FREAcquireByteArray (objectByteArray, & byteArray);

memcpy (byteArray.bytes, jpgData.bytes, jpgData.length);

FREReleaseByteArray (objectByteArray);

output bits

CGColorSpaceRelease (colorSpaceRef);

CGImageRelease (imageRef);

CGDataProviderRelease (provider);

return null;

}

Tags: Adobe AIR

Similar Questions

  • ANE iOS game in 1.4 is not supported beta air16

    ANE iOS game in 1.4 is taking does not support beta air16, where the game will be updata and fix this error?

    Thanks for getting back.  AIR 16 compatible with iOS 64-bit, the ANE all should be done with universal binary support (32 and 64 bit).  We will work on getting the Gaming SDK samples updated accordingly.

    Thank you

    Chris

  • DONKEY to a platform on the mobile Flex project for iOS and Android

    I'm very new Flex Mobile projects and native extension.

    I have a big doubt... If I have a DONKEY which only works on iOS or Android, can I use it in a project for Android AND iOS?

    I mean, if I want to do something and I only found and DONKEY who works for the iOS and another DONKEY that works for Android, can I create only one project and according to the device, use one or the other? or do I have to create two different projects?

    Thanks in advance

    You can set both upward and when you publish simply comment out the code that does not, in this way, you always keep it as a single project, but you can use the ANEs as needed, I had to do this with the DONKEY SAI only for obviously Apple and AdMob DONKEY which at the time was Android only.

    Example of

    ANE Android Code
    blah blah blah
    iOS Code
    code code code

    Now when you publish to iOS comment things Android related

    ANE Android Code

    /*

    blah blah blah

    */

    iOS Code

    code code code

    Don't forget to update your donkeys included when you publish and delete those that don't apply and update XML files as needed. Its possible, but boring, it would be nice if it was automated or may be reported in some way so the Flash editor would automatically ignore it.

  • My 5s iphone suddenly showed no service, then I made an attempt to update to ios and itunes connected, now iphone is not enable and display cannot connect to the server and in itunes it shows unable to check your device.please help me

    My 5s iphone suddenly showed no service, then I made an attempt to update to ios and itunes connected, now iphone is not enable and display cannot connect to the server and in itunes it shows unable to check your device.please help me

    Assuming that you have a valid SIM card in the phone, it is more often symptomatic of a phone that has been hacked or jailbroken to unlock.

    Where do you have the phone first?

  • It does not sync between iOS and windows laptop.

    I just downloaded firefox for iOS and logged into my account from firefox. I did the same thing on my windows laptop 10 and synchronized together. No story appeared. It says that I have not all devices connected to this account of Firefox to synchronize. What's wrong?

    Hello
    I understand that for the moment that history is no synchronization between a Device IOS and office. I'm happy to help you.

    First of all, what measures do you take to see this "You have not all devices connected to this account of Firefox", second, in the settings on the PC sync, is checked for synchronization history?

    For troubleshooting, first try to restart the synchronization by going to the gear icon and logout at the bottom of the menu. Erase cache cookies private then re-launch of the app and the connection.

    This aid?

  • 9.3.3 iOS and Windows XP, iTunes error 80090326

    9.3.3 iOS and Windows XP, iTunes error 80090326

    Run the latest version of iTunes 32bits version 12.1.3.6

    Windows XP SP3

    iPhone 4 running iOS 7.1.2 can connect to iTunes without problem

    iPhone 4 running iOS 9.3.3 s cannot connect to iTunes: error 0 x 80090326

    Have tried to reinstall iTunes, QuickTime, without success to 'fix '.

    With the help of Microsoft KB 968730, tried to add support for SHA-256 encryption by applying the XP 375554 fix, without success.

    Looks like the XP upgrade to > = Windows 7 is the only solution that works.

    Someone at - it solutions for connect an iPhone running iOS 9.3.3 to iTunes on Windows XP?

    Important information, I forgot to mention:

    The iPhone 4S running iOS 9.3.3 was completely wiped out and showed the "Welcome" screen

    I restored from backup to iCloud live and from that moment, I could connect the phone using iTunes

    It is therefore some kind of problem with a blank iPhone, not yet implemented at all.

  • Parachute does not not between iOS and Mac devices... Does anyone have a good solution for it nor a lot of garbage to support

    Parachute does not not between iOS and Mac devices... Does anyone have a good solution for it nor a lot of garbage to support

    You want the solution? Why not tell us what Mac and Apple, mobile devices you have the OS and version?

    Also what troubleshooting steps you took?

    We do not have a crystal ball, and we're not sitting next to you.

  • I use a HP computer, when I try to load Mozilla home page says I use an iOS and does not load

    When I try to open the home page of Mozilla it says it can not open with an iOS and my computer does not meet the requirements. I use a HP computer. He used to pen without problem until I upgraded to version 33. I had to use my IE browser in order to send it to you. In my browser IE Mozilla home page opens correctly.

    PROBLEM SOLVED

    OK James, I was able to understand the problem. I use Avast Anti-virus program. It offers a feature called "Home Network Security" when I updated to the latest version, I thought I'd give this feature a try. I went and disabled this feature, and was able to get the Mozilla Web site to load properly. What I don't understand is why he just did with Mozilla's Web site and only if you are using Firefox. It didn't do it using IE or Maxthon browsers.

    anyway thanks a lot for the answer to my problem and try to solve it. When you said "it could be due to a proxy or even external software that changes the browser identifies itself asonline. It made me remember the change that I did with the Avast anti-virus program.

  • Why Apple can't do two systems? First of all, we are protected, and the other is free just like android, but in the style of the iOS and Apple needs a request so we can manage and see new products from an application and do not go on this site!

    Why Apple can't do two systems? First of all, we are protected, and the other is free just like android, but in the style of the iOS and Apple needs a request so we can manage and see new products from an application and do not go on this site!

    and I don't know that if Apple make a system more freely, there no need for any device on Earth but iPhone.

    http://www.Apple.com/feedback/

  • Safari and mail app freeze 9.2.1 ios and ios 9.3

    Safari and mail app freeze on my ipad mini 4 (9.2.1 ios and ios 9.3) in these last two days each time if I touch to create a link in the email or on the web page.

    I tried to turn off the power of java script in safari... always gel

  • iPhone 4 cannot be updated (iOS and apps)

    Hello community

    I have an iPhone 4 with an iOS installed 7.1.2. I am trying to download a new application that I did not and I get the message "unable to download. "This app requires iOS 8 or newer. I have it plugged into my pc and it is not possible to update the version of iOS through iTunes. So I can't update the iOS and of course it is not possible to obtain a new application or even to update an already installed application.

    What can I do with this? Can I do something to get my app that I need?

    Thanks in advance!

    7.1.2 IOS is the latest software available for the iPhone 4

    Install the latest compatible version of an application on an older version...

  • Orders between IOS and IOS - XE devices?

    Hi all

    Is there a difference in order between IOS and IOS - XE routers?  If Yes, can you please share more details on the same?

    Thank you

    Sunil Kumar

    Hello

    Most of the commands are the same for both IOS and IOS - XE.

    Here's more information:

    http://www.Cisco.com/c/en/us/products/collateral/iOS-NX-OS-software/iOS-...

    HTH

  • MAF: Is the PushNotificationConfig Interface for IOS and Android?

    Hey Oracle Community.

    Regarding the

    PushNotificationConfig


    Issues related to the:

    1. Is this Push Notification for IOS and Android interface?  IOS is APNs and uses alerts / icon Badging.  Android is GCM and uses Notifications /Alerts (in the notification bar).
    2. Y at - it a LocalNotifications hook?

    Can you tell me the exact link to view the source code?


    Thank you!

    Theresa


    Hello

    (1) Yes, push notification works with iOS and Android. Details are provided in the product documentation

    (2) No, you're always going through Apple or Google notification services

    MAF and ADF Mobile are associated with this connection and give it links following code samples

    https://blogs.Oracle.com/mobile/entry/push_notification_support_and_provide

    Unwinding ADF: ADF Mobile Push Notifications with Google Cloud messaging (MCM) part 1

    Frank

  • Would it not be possible to capture the camera on mobile devices (ios and android)?

    Mr President.

    I don't have frind and support, but I have a question to ios and android, for should I check the video of

    Adobe Flash Profession.I understand that we can design code for Android and IOS and compile, package

    in Flash applications, but my problem is would be possible camera capture (input) on mobile and ouput devices a H.264 files.

    I have a friend in this world, can you let me know, I'm not alone, I need to fight for my faith the mobile phone isn't troublemaker... @.

    You can access the data in the library using the cameraroll class.

  • 5.1 Lightroom ceased to import JPEGs of iPhone. The iphone and the images will be displayed, but import said that they cannot be read. This has just begun. Even the phone, IOS and the OS.

    5.1 Lightroom ceased to import JPEGs of iPhone. The iphone and the images will be displayed, but import said that they cannot be read. This has just begun. Even the phone, IOS and the OS.

    The message 'could not be read' indicates you do not have WRITE permission on the destination folder. So, here's what you need to do

    1. The Lightroom Import dialog box, go to the Destination section to the right and make a note of the specified folder.
    2. Change the folder to something else; OR in your operating system, change the permissions on this specific file WRITE permission.

Maybe you are looking for

  • Apps are not up-to-date

    6plus IPhone updated some apps yesterday and left more than 154 apps waiting to be updated. No matter what I do, can't do the remaining applications to update. Your help to solve this problem is appreciated. I have a fast wifi and the phone is slow i

  • Help! I can't install or remove windows 7!

    Ihad a win7 32bits permeable system However iwant change to 64-bit butafter I deleted thebootcamp keep not showing this message idonknowwhats passes and what shouldido cansomeone help please! hereismy commands Last login: Sun Sep 4 00:39:54 on ttys00

  • E545 brightness is not setting

    When I opened my laptop E545 after sleeping, I find that the brightness shortcut keys do not work (like other keys, volume, work). Only after the deactivation and reactivation of my graphic card or by restarting the computer entirely, brightness shor

  • Firewalls

    How is it important to have the firewall checked on my WRT1900AC?

  • My Win 7 Desktop is upside down

    I pressed a button somewhere and the screen turned upside down.  How to get right to the top? Original title: Uh-oh, my Win 7 Desktop is upside down