File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Mobile » Android
Bookmark "Save an ImageView as a png file" Watch "Save an ImageView as a png file" New topic

Save an ImageView as a png file

R. La Com

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 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):
R. La Com

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 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 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

I agree. Here's the link:
subject: Save an ImageView as a png file
It's not a secret anymore!