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

Web and WebWorks Development

Reply
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

Did you read the link I gave you? it's for playbook

Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

Yes, I do
And I fix my config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" id="idRetailStar"

version="1.0.0.0">
<name>MyAppExample</name>
<description>RightStar</description>
<author email="phan@tma.com.vn">An Pham</author>

<feature id="blackberry.identity" required="true" version="1.0.0.0"/>
<feature id="blackberry.message" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.file" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera"/>
<feature id="blackberry.find" required="true" version="1.0.0.0"/>
<feature id="blackberry.app" required="true" version="1.0.0.0"/>


<feature id="blackberry.system" />
<feature id="blackberry.connection" />
<feature id="blackberry.invoke"/>
<feature id="blackberry.utils" />

<feature id="blackberry.app.event"/>



<icon rim:hover="false" src="WebContent/images/app_logo.png"/>
<icon rim:hover="true" src="WebContent/images/app_logo.png"/>

<content src="login.html">

</content>

<rim:smileysurprised:rientation mode="landscape" />


<rim:loadingScreen backgroundColor="#063a6b"
onFirstLaunch="true"
onRemotePageLaunch="true"
onLocalPageLoad = "true">
<rim:transitionEffect type="zoomIn" direction="slideOver" duration="1000"/>
</rim:loadingScreen>

<access subdomains="true" uri="file:///accounts/"/>

<rim:smileytongue:ermissions>
<rim:smileytongue:ermit>access_shared</rim:smileytongue:ermit>
<rim:smileytongue:ermit>read_geolocation</rim:smileytongue:ermit>
<rim:smileytongue:ermit>use_camera</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>

</widget>
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

i think the IO feature element should go inside the access element.

What error are you getting?

Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

No, I don't see err
Although I use try{}catch(err){}

function saveImg (url) {
try {
var _now = new Date();
var fileName = _now.getDate().toString()+(_now.getMonth()+1).toString()+_now.getFullYear().toString()+_now.getHours().toString()+_now.getMinutes().toString()+_now.getSeconds();
var dirs = blackberry.io.dir.appDirs;
var image_path = dirs.shared.camera.path+'/Rs'+fileName+'.png';
alert(image_path);

var image01 = document.createElement('img');
var myCanvas = document.createElement("canvas");
var mycanvas_context;

image01.onload = function() {
myCanvas.width = image01.width;
myCanvas.height = image01.height;
mycanvas_context = myCanvas.getContext("2d");
alert(image01.width + ' x '+image01.height);

mycanvas_context.drawImage(image01,0,0);

final_image = myCanvas.toDataURL("image/png");

final_image_blob = blackberry.utils.stringToBlob(final_image,"BASE64");
blackberry.io.file.saveFile(image_path, final_image_blob);
};
image01.src=url;

/*var _imgShow = document.getElementById('imgTmpShow');
_imgShow.src=image_path;*/

} catch(e) {
alert("Err. "+e);
}
}
Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Issue about saveFile (image)

Debug it with the inspector. Let us know when you find out what the error is

Nuno
Regular Contributor
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: Issue about saveFile (image)

Thanks for your help.

 

I am done. ^^