jQuery in Action, 2nd edition*
The moose likes Android and the fly likes Save an ImageView as a png file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Save an ImageView as a png file" Watch "Save an ImageView as a png file" New topic
Author

Save an ImageView as a png file

R. La Com
Greenhorn

Joined: Jun 12, 2012
Posts: 2
I tried posting this question earlier. I do not see it anywhere, so I am giving it another try.

I have been working on program (ReDrawa) to open an image (right now Colors.png, attached), change the color(s), and then save the changed image to the SDcard.


All goes well except for the saving. I have two methods that I have tried with some success.



This saves what I call an empty file. It does not show up in the Gallery. However, when I adb pull /sdcard/out0.png, it pulls out a file with no image (I cannot open the file) it is listed as having 0K.


The second method comes from code I saw on line that saves the R.drawable.icon. When I try to change it to R.id.imageView1 there is no error but again it is an empty file.



In DDMS there is a Null Pointer warning. So I am thinking that I have not connected imageView1 to bmp.

Thanks in advance for the help.




[Thumbnail for colors.png]

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
To save it to the gallery (which is what I think you may really want to do).



If you really want to save it to the SD card, then this should walk you through it (note that a simple Google search provided this): http://android-er.blogspot.com/2010/07/save-file-to-sd-card.html
R. La Com
Greenhorn

Joined: Jun 12, 2012
Posts: 2
Thank you for your quick reply.

I think that I do want to save to the SD card. But I will certainly give your code a try.

I know about the code at the http://android-er.blogspot.com/2010/07/save-file-to-sd-card.html site. I have seen it
there and elsewhere in my web searches. I had discounted it being a guide for my project because, it loads an image
from the Internet using a URL. Whereas I am loading an image from a SD card (I added to my code an user input file
name). Also it saves the image using the URL (plus I suspected that it saved the web image rather than saving the
rendered image in my imageView).

I went to http://android-er.blogspot.com/2010/07/save-file-to-sd-card.html again and I tried cobbling its save code
into my project. I think I ended up with a hidious hybird. My attempt did not compile. I will put that aside until I try out
the code you suggest. My harddrive appears to be going wonky; it looks as tho I need a new one, so it may be awhile before
I can give it a go.

Thank You




 
wood burning stoves
 
subject: Save an ImageView as a png file
 
Similar Threads
Not able to write the image to file
how to upload image from android to restful webservice using jersey
Multiple Checkboxes in ListView
How to set the bitmap height at runtime
how to create restful webservice using jersey to consume image from android client