objective-cmacosactionscript-3air-native-extension

Sending NSImage to AS3. AIR Native Extension(ANE)


In my native objective-c code I have a NSImage. How can I send it to as3 code, so I could use addChild(NSImageFromNative) method in my as3 project?


Solution

  • In addition to your solution, you can create a BitmapData in native code like that:

    // first get those values from NSImage
    FREObject contructorArguments[4] = { width, height, transparent, fillColor };
    
    // create an instance of BitmapData
    FREObject freBitmapData;
    FRENewObject((uint8_t *)"flash.display.BitmapData", 4, contructorArguments, &freBitmapData, NULL);
    
    // now acquire the bitmap data in order to manipulate it
    FREBitmapData acquiredFreBitmapData;
    FREAcquireBitmapData(freBitmap, &acquiredFreBitmapData);
    

    After that you can copy pixels from NSImage to FREBitmapData.