Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:36:04+00:00 2026-06-03T03:36:04+00:00

For an Android Flash Mobile App I try to grab a Preview-frame from the

  • 0

For an Android Flash Mobile App I try to grab a Preview-frame from the camera.

Unfortunately I can’t use the AIR Built-in Camera class because the camera isn’t focusing unless I call setMode() (which is unacceptable because it freezes the UI).

So I decided to write a Native Extension for this. The extension itself is working (I get the proper Image data in NativeCamera.pixels) but I can’t transmit the Frame using FREBitmapData. On ActionScript side the BitmapData has the right dimension, but it remains black.

My Java-Code

package com.jumptomorrow.nativecamera;

import java.nio.ByteBuffer;

import com.adobe.fre.FREBitmapData;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;

public class NativeCameraGrabFrameFunction implements FREFunction {

    @Override
    public FREObject call(FREContext context, FREObject[] object) {
        try {
            FREBitmapData out = null;

            try {
                out = FREBitmapData.newBitmapData(NativeCamera.size.width, NativeCamera.size.height, false, new Byte[]{0xf,0xf,0x0,0x0});
                out.acquire();
                ByteBuffer bb = out.getBits();
                bb = ByteBuffer.wrap(NativeCamera.pixels);
                out.invalidateRect(0, 0, NativeCamera.size.width, NativeCamera.size.height);

            } catch (Exception e) {
                e.printStackTrace();
            } 

            try {
                out.release();
            } catch(Exception e) {
                e.printStackTrace();
            }

            return out;

        } catch (IllegalStateException e) {
            e.printStackTrace();
        } 

        return null;
    }

}

My ActionScript Code

package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.utils.ByteArray;

    import net.hires.debug.Stats;

    public class camera_test extends Sprite
    {
        private var nc:NativeCameraInterface;
        private var bitmap:Bitmap;

        public function camera_test()
        {
            super();

            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            nc = new NativeCameraInterface();
            try {
                nc.startCamera();
            }
            catch(e:Error) {
                trace(e.getStackTrace());
            }

            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        protected function onEnterFrame(event:Event):void
        {
            if(nc) {
                var bmpd:BitmapData = nc.getFrame() as BitmapData;

                try {
                    var bmp:Bitmap = new Bitmap(bmpd);

                    addChild(bmp);
                    bmp.scaleX = bmp.scaleY = 2;

                } catch(e:Error) {
                    trace("failed");
                }
            }
        }
    }
}

Has anyone an idea what this could be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:36:05+00:00Added an answer on June 3, 2026 at 3:36 am

    Shouldn’t these lines…

    ByteBuffer bb = out.getBits();
    bb = ByteBuffer.wrap(NativeCamera.pixels);
    

    … be something like this?

    ByteBuffer bb = out.getBits(); // (no change)
    bb.position(0);
    bb.put(ByteBuffer.wrap(NativeCamera.pixels));
    

    This modifies the ByteBuffer instance obtained through out.getBits(), instead of creating a new ByteBuffer instance through bb = ByteBuffer.wrap(...).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i send a flash sms from my android handset ? q.2. how to
I'm developing a mobile app using Flash Builder 4.6/AIR. I've been able to debug
I am working with Amazon In-app-purchases for Android on flash using native extentions. So,
I need to test my Android app for playing flash objects in the WebView.
Possible Duplicate: How Turn on only Camera flash light programmatically in android? I am
So I've created an android app that plays video from blip.tv and various other
I'm currently working on converting an Android app I built natively as an iPhone
I want my Phonegap App to open a Flash-Webpage in the Android Browser, not
I am building a Android app in Flash Builder 4.5 using Flex 4.5.1 and
Can Flash Media Server 3.5 serve a video rtsp stream to the Android media

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.