mariettaengle / diadraw-air-camera-native-extension

Automatically exported from code.google.com/p/diadraw-air-camera-native-extension
0 stars 0 forks source link

Like Negative! #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I0m using your ANE on flash cs6... but i have a bad camera result (view the 
screenshot)

this is the code

function handleImageReady( _event : NativeCameraExtensionEvent ) : void
{

// Create a ByteArray to get the frame data into. You don't need to resize the 
array:
    m_byteArray = new ByteArray();                   
    var currentFrameIdx : Number = m_cameraExt.getFrameBuffer( m_byteArray, m_lastFrameIdx );

    // Check if we have already got this frame:                                
    if ( currentFrameIdx != m_lastFrameIdx )
    {
        m_lastFrameWidth = _event.frameWidth;
        m_lastFrameHeight = _event.frameHeight;

        // Extract BitmapData from the ByteArray
        var bd:BitmapData = new BitmapData( m_lastFrameWidth, m_lastFrameHeight, true );
    bd.setPixels(new Rectangle(0,0,m_lastFrameWidth,m_lastFrameHeight), m_byteArray );
       var bb_ :Bitmap = new Bitmap(bd);
       while (m_image.numChildren > 0) {
        m_image.removeChildAt(0);
       }
       m_image.addChild(bb_);

        // Perform any pixel processing here

        m_lastFrameIdx = currentFrameIdx;
    }       
}

Original issue reported on code.google.com by ynfo.a...@gmail.com on 26 Jun 2013 at 12:01

Attachments:

GoogleCodeExporter commented 8 years ago
PS I'm using an iPad WiFi 3th gen - iOS 6.1.2

Original comment by ynfo.a...@gmail.com on 26 Jun 2013 at 12:07

GoogleCodeExporter commented 8 years ago
Hi ynfo.apps, apologies for the late reply!

The pixel data comes from the native side ordered as little endian, which 
explains the swapped colours you are seeing. ActionScript's BitmapData would by 
default expect it as big endian. You can set the ByteArray to be read as little 
endian before it's displayed:

m_byteArray.endian = Endian.LITTLE_ENDIAN;

You can see the full example in the test app: 
https://code.google.com/p/diadraw-air-camera-native-extension/source/browse/Flex
App/src/views/CameraTestAppHomeView.mxml

Cheers,
Radoslava

Original comment by Radoslava.Leseva on 17 Jan 2014 at 2:26