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
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

loading camera and external image help

So I have a file browswer created and i'm able to select a file from the browser and it returns the filepath

like this

 

accounts/1000/shared/camera/IMG_00000053.jpg

 

I then use the filepath and try to load the picture and is crashing. 

 

    rc = img_load_file(ilib, "accounts/1000/shared/camera/IMG_00000053.jpg", null, &img);

 

is the above correct or I need to add something to the path?

 

I can load a image from the asset fine like this

 

    rc = img_load_file(ilib, "app/native/test.jpg", null, &img);

 

thanks

 

 

 

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: loading camera and external image help

For the shared folder, you should use shared/camera/... instead of /accounts/1000/shared/camera. Each app gets its own symlink to /accounts/1000/shared in its sandbox folder as ./shared .

(This won't work if you change your current directory, but that's almost certainly something nobody *needs* to do.)

In any case, to access shared through either path, you'd need to specify the correct access permission (access_shared) in your bar-descriptor.xml file.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: loading camera and external image help

thanks for but i'm stilling having issues.  already have file access set.

I have use the following

file:///shared/camera/IMG_00000053.jpg

file:///accounts/1000/shared/camera/IMG_00000053.jpg

and it says no such directory.

If I use shared/camera/IMG_00000053.jpg it crashes.

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: loading camera and external image help

Sounds like you need to try some debugging or add some logging to assist you in figuring out the problem. If you get "no such directory" with those other approaches, chances are the only one that doesn't give you that error is actually working, as in finding the file correctly. At that point, I'd expect it's your other code that's at fault in the crash.

Do you know how to get the log file out of the system when your app crashes? What you see in it should point you more specifically to the source of the problem.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: loading camera and external image help

I know the file is there because it use the file browser to pick it.

 

The error msg is displayed from my debug code in the console.

 

do you know the format of the filename? does it require file:// connection and then the full path?

 

do you have example with the correct filepath when loading a file?

 

thanks

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: loading camera and external image help

It's just a simple path string, nothing special with a URL scheme or anything. In the past I've used it with "shared/documents/scripts/logo.png" when I was testing something out, and it worked fine.

I really think figuring out how to retrieve your logs/log file and seeing what it tells you would be a good idea.

Stray thought: your showed "null" in your code above, but generally speaking you wouldn't have something called that in C code, but rather NULL. Any chance you've done something funky with that, or was it just a typo from re-typing the code here?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: loading camera and external image help

I wish there are more dev docs from RIM and i've been reading some of your past notes and still couldn't figure out. All I really want to do is read the picture from the camera folder.

 

Here is my exact code

 

const char *img_path = "/shared/camera/IMG_00000053.jpg";

 

    rc = img_load_file(ilib, path, &callouts, &img);
    if (rc != 0)
        perror("loading err: ");

 

I have tried many different ways for the path and nothing works. 

 

Very frustration...

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: loading camera and external image help

That last one won't work because it has an absolute path to a folder that does not exist. When you start a path with / it starts at the root folder... there's no subfolder named "shared" there, so /shared is invalid.

Try without the forward slash... just "shared/camera/IMG_00000053.jpg".

If it crashes, suspect something else you're doing, like how you've initialized callouts or img, or whether ilib is valid, etc... not the path.

Also check for that log file...

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: loading camera and external image help

[ Edited ]

Thanks peter9477.  The problem was with the callout.  The image was too big for the screen.

 

 

I read one can use ImageView.  is that only for cascade?