andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

Using CameraPreview to save a picture on disk

Goto page Previous  1, 2, 3  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials
Author Message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2624
Location: College Park, MD

PostPosted: Thu Jan 03, 2008 11:48 am    Post subject: Reply with quote

Hello Katharnavas,

saving takes place here:
Java:
                   FileOutputStream stream = super.openFileOutput("picture" + i++ + ".png", MODE_PRIVATE);
                    camera.capture(canvas);
                    myPic.compress(CompressFormat.PNG, 100, stream);
                    stream.flush();
                    stream.close();

Simply alter the Parameter of super.openFileOutput(...);. If you want to write to the SD-Card, there is no need for using "openFileOutput", because you can use standard java methods, like new FileOutputStream(...)...

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile

| Android Development Community / Tutorials


Last edited by plusminus on Thu Jan 03, 2008 2:02 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Katharnavas
Senior Developer
Senior Developer


Joined: 04 Dec 2007
Posts: 100
Location: India

PostPosted: Thu Jan 03, 2008 1:11 pm    Post subject: Reply with quote

Hi,
Its nice to have you after a pleasant new year ...
Back to top
View user's profile Send private message Yahoo Messenger
Lex
Developer
Developer


Joined: 16 Nov 2007
Posts: 30

PostPosted: Thu Jan 03, 2008 1:29 pm    Post subject: Reply with quote

Thank you for this tutorial. Very helpful !
Back to top
View user's profile Send private message
bavarol
Experienced Developer
Experienced Developer


Joined: 10 Dec 2007
Posts: 52

PostPosted: Thu Mar 06, 2008 12:10 pm    Post subject: Reply with quote

plusminus wrote:
Hello Katharnavas,

saving takes place here:
Java:
                   FileOutputStream stream = super.openFileOutput("picture" + i++ + ".png", MODE_PRIVATE);
                    camera.capture(canvas);
                    myPic.compress(CompressFormat.PNG, 100, stream);
                    stream.flush();
                    stream.close();

Simply alter the Parameter of super.openFileOutput(...);. If you want to write to the SD-Card, there is no need for using "openFileOutput", because you can use standard java methods, like new FileOutputStream(...)...

Regards,
plusminus

Hi, I have written "-sdcard <path of sdcard.img>" on command line as ever, then I altered super.OpenFileOutput by new FileOutputStream(...) in all possible variants (new FileOutputStream(String), new FileOputputStream(File), etc) but I still get FileNotFoundException, why?

Regards
Back to top
View user's profile Send private message
bavarol
Experienced Developer
Experienced Developer


Joined: 10 Dec 2007
Posts: 52

PostPosted: Thu Mar 06, 2008 3:42 pm    Post subject: Reply with quote

I have solved my problem, it was cause of hidden directory without permission to write

That works fine
Java:
FileOutputStream stream = new FileOutputStream("/sdcard/dsc" + i++ + ".png");


Thx Wink
Back to top
View user's profile Send private message
drhu00
Junior Developer
Junior Developer


Joined: 12 Feb 2008
Posts: 11

PostPosted: Sat Mar 08, 2008 5:31 pm    Post subject: How to retrieve the png file that I saved? Reply with quote

I can save these png files as said in this post
picture0.png
picture1.png
etc.

but how can I get back these pictures?
Back to top
View user's profile Send private message Visit poster's website
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2624
Location: College Park, MD

PostPosted: Sat Mar 08, 2008 5:49 pm    Post subject: Reply with quote

Hello drhu,

have a look at this tutorial: http://www.anddev.org/viewtopic.php?t=115

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
drhu00
Junior Developer
Junior Developer


Joined: 12 Feb 2008
Posts: 11

PostPosted: Sat Mar 08, 2008 6:11 pm    Post subject: Reply with quote

Thank you plusminus. The question is that when I use your filebrowser
http://www.anddev.org/android_filebrowser__v20-t101.html
under the data, I find it is empty so I can't find the
/data/data/org.picture/files/picture0.png
That's why I am wounder where is the file stored.

Does your filebrowser can retrive all the directory and files under data? Why it is empty? When I use the eclipse DDMS shows all the files and directory.
Back to top
View user's profile Send private message Visit poster's website
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2624
Location: College Park, MD

PostPosted: Sun Mar 09, 2008 1:35 pm    Post subject: Reply with quote

Hello drhu00,

the reason for that is the rights, the application is running with.
You need administrator-priviledges to browse that folder, which a normal application has not.

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Steel
Developer
Developer


Joined: 28 Dec 2007
Posts: 43
Location: Copenhagen, Denmark

PostPosted: Tue Mar 11, 2008 4:24 pm    Post subject: Reply with quote

A fine tutorial indeed.

I wonder about the quality hint in the Bitmap.compress(...)-function though. The javadoc says:

quality Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality.

Now thats fine and logical for the JPEG-compressor, but for the PNG-compressor shouldn't it be 1-8 (BitsPerPixel for PNG-8) or 24 (for PNG-24)?

Issue 443 filed.

_________________
Eclipse is a fork, IntelliJ is the ninja sword. Which weapon are you going into battle with?
Back to top
View user's profile Send private message MSN Messenger
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2624
Location: College Park, MD

PostPosted: Tue Mar 11, 2008 5:21 pm    Post subject: Reply with quote

Hello Steel,

I don't know. Maybe they are wrapping the values internally , depending on what file-type was selected.

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Pere
Freshman
Freshman


Joined: 11 Apr 2008
Posts: 2

PostPosted: Fri Apr 11, 2008 6:11 pm    Post subject: Reply with quote

Hi,

I'm an absolute beginner with Android. I found this site and started practicing with the nice tutorials it provides. Then I found this one which has something to do with what I wanted to do with Android, so I think it would be a good start point to base my project on.

But I'm having problems getting it to work right from the beginning. I downloaded camera.zip, put into my Eclipse project folder and tried to run it. First of all I got a problem because the android.jar folder was configured in another path (probably for a Unix system). After fixing that, I get the following errors:

"the method setCallback(Preview) is undefined for the type SurfaceHolder" (file CameraPreview.java, line 136).

"the return type is incompatible with SurfaceHolder.Callback.surfaceCreated(SurfaceHolder)" (file CameraPreview.java, line 164).

About the 1st error, as Eclipse gives me the option to change the method to "addCallback", I supposed the method just could had changed its name in a newer version of the API or whatsoever; I am using last version of the API and maybe this tutorial could have been done using an older version.

For the 2nd one, I have no clue. I simply tried changing the return type to "void" to try to run it... and then, after I try to run the project from the "Run" dialog, I get a "Project is not an Android Project. Aborting!" error in Eclipse.

I would be very happy if someone could enlight me with some help to get this running...

Thanks a lot!
Back to top
View user's profile Send private message
Stephen.Ada
Junior Developer
Junior Developer


Joined: 10 Mar 2008
Posts: 10

PostPosted: Sun Apr 20, 2008 5:55 am    Post subject: Reply with quote

a nice tut.

I did save some pictures in the dir . but the picutre did't display what it is as i capture in android.

the first picture display like this:


but the successive captured picture can't display ,however....

have u guys ever encourtered this problem?

any help appreciate!



picture0.png
 Description:
 Filesize:  1.31 KB
 Viewed:  1968 Time(s)

picture0.png


Back to top
View user's profile Send private message Send e-mail Visit poster's website
Pere
Freshman
Freshman


Joined: 11 Apr 2008
Posts: 2

PostPosted: Fri Apr 25, 2008 4:56 pm    Post subject: Reply with quote

Hi again,

Please, can anyone give me some hint in getting my problem solved? I haven't touched a line of the source code provided, but still I am not able to run it.
Back to top
View user's profile Send private message
bavarol
Experienced Developer
Experienced Developer


Joined: 10 Dec 2007
Posts: 52

PostPosted: Wed Jun 04, 2008 7:30 pm    Post subject: Reply with quote

Pere wrote:
Hi again,

Please, can anyone give me some hint in getting my problem solved? I haven't touched a line of the source code provided, but still I am not able to run it.

Pere wrote:
Hi,

I'm an absolute beginner with Android. I found this site and started practicing with the nice tutorials it provides. Then I found this one which has something to do with what I wanted to do with Android, so I think it would be a good start point to base my project on.

But I'm having problems getting it to work right from the beginning. I downloaded camera.zip, put into my Eclipse project folder and tried to run it. First of all I got a problem because the android.jar folder was configured in another path (probably for a Unix system). After fixing that, I get the following errors:

"the method setCallback(Preview) is undefined for the type SurfaceHolder" (file CameraPreview.java, line 136).

"the return type is incompatible with SurfaceHolder.Callback.surfaceCreated(SurfaceHolder)" (file CameraPreview.java, line 164).

About the 1st error, as Eclipse gives me the option to change the method to "addCallback", I supposed the method just could had changed its name in a newer version of the API or whatsoever; I am using last version of the API and maybe this tutorial could have been done using an older version.

For the 2nd one, I have no clue. I simply tried changing the return type to "void" to try to run it... and then, after I try to run the project from the "Run" dialog, I get a "Project is not an Android Project. Aborting!" error in Eclipse.

I would be very happy if someone could enlight me with some help to get this running...

Thanks a lot!

Hi Pere (are you from Catalonia?Wink), you should use CameraPreview of APIDemo, start the emulator and then click over ApiDemo and go to "graphic", and you'll find CameraPReview. I think it's still there.
I still work under m3rc22 cause of my Project.

So you have not to download cameraPreview.zip from this post.

Bye
Adios
Adeu
Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.