Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 1,636
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

I want to copy camera image data. Is this how?

[ Edited ]

 

 

                memcpy(data, &buf->framebuf, buf->framedesc.jpeg.bufsize);

 

What is the correct way to copy the data to memory?  thanks

 

Developer
Posts: 162
Registered: ‎01-11-2012
My Device: BlackBerry 9790, BlackBerry PlayBook 64Gb, BlackBerry 10 Dev Alpha
My Carrier: MTS

Re: I want to copy camera image data. Is this how?

Hi smiley,

Try the following:

memcpy(data, buf->framebuf, buf->framedesc.jpeg.bufsize);
Respectfully,
Oleg

Developer, QNX RTOS, BlackBerry 10 and PlayBook
Follow me on Twitter (in Russian)
St.Petersburg BlackBerry Dev. Group
Developer
Posts: 1,636
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: I want to copy camera image data. Is this how?

[ Edited ]

thanks.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: I want to copy camera image data. Is this how?

This is the correct way to copy jpeg data.  this will only work if (buf->frametype == CAMERA_FRAMETYPE_JPEG).

For other frametypes, you may need to do more elaborate copies.

Cheers,

Sean

Developer
Posts: 1,636
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: I want to copy camera image data. Is this how?


smcveigh wrote:

This is the correct way to copy jpeg data.  this will only work if (buf->frametype == CAMERA_FRAMETYPE_JPEG).

For other frametypes, you may need to do more elaborate copies.

Cheers,

Sean


Thanks.  On a related problem with the camera NDK example.  How do I renable the viewfinder when the screen auto timer goes off?  When I turn the PB back on the viewfinder does not get refresh and stays black.

 

Is there an window refresh event that need to be handled in the event function?

Highlighted
BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: I want to copy camera image data. Is this how?

I am going to mention some best-practises for dealing with standby mode here...

 

Is this a purely native sample, or cascades?

If it is purely native - eg. you have a handle to an application window, then you should be able to apply SCREEN_IDLE_MODE_KEEP_AWAKE to your window.  So long as your app is visible, the device will remain awake.

https://developer.blackberry.com/native/documentation/com.qnx.doc.native_sdk.devguide/com.qnx.doc.na...

 

If you are doing this via cascades, I do not know if an equivalent API exists yet.  In general unless you are doing a video recording, the screen will be allowed to time-out.  When video recording is active, the viewfinder itself will have the keep-awake applied.

 

You should also be seeing status callbacks which indicate that the camera is powering down.  Once your app receives an appropriate navigator event indicating that it is back in the foreground again following a wake-up, you will have to re-start the viewfinder.  eg. stop and start it again.

 

Lastly, there is an API (in R6 I think) which can be used to indicate to the camera service that your app may be using buffers and that you want to be notified early that a shutdown is about to happen.  When a shutdown happens, your buffers are forcefully unmapped, which could cause your app to crash unless you are careful.  You can call the camera_register_resource() function to let the camera service know that you may be using buffers.  Once a CAMERA_STATUS_RESOURCENOTAVAIL status event is received, you must immediately cease using any buffers and call camera_deregister_resource() to allow shutdown to proceed - including unmapping your buffers.  You only have one or two seconds to do your cleanup before it will timeout and proceed regardless.

Note that camera_register_resource() and camera_deregister_resource() are purely an increment/decrement-type function.  Each call to camera_register_resource() must be eventually matched with a call to camera_deregister_resource() otherwise you are going to be impeding shutdown performance.

 

(I would link you to the docs on those 2 functions, but it looks like the docs site has a broken link to camera_register_resource which I will have to get someone to fix)

 

Cheers,

Sean