How to get image file from Google Chart API

by AlBasha » Wed, 29 Oct 2008 22:55:28 GMT


Sponsored Links
 I'm trying to get image file from Google Chart API.
Image link (strURL) =
 http://chart.apis.google.com/chart?cht=p& ;chd=t:37,0,50,12,1,0,0&chs=300x200&chl=Agriculture||Shrub/Grass|Trees|Built|Bare/Ice|Water&chco=FFFF66,ffffff,99FF66,006600,cc0000,cccc66,76A4FB&chf=bg,s,d3d3d3&chdl=Agriculture||Shrubs
and Grass|Trees|Built|Bare or Ice|Water&chdlp=b

Here is my java code:
URL url = new URL(strURL);
BufferedImage original = ImageIO.read(url); ---> Error when reach here
byte[] data = write(original, "png");

Here is the error  :
javax.imageio.IIOException: Can't get input stream from URL!
at javax.imageio.ImageIO.read(Unknown Source)

Any idea?



--~--~---------~--~----~------------~-------~--~----~



How to get image file from Google Chart API

by Ludwig » Thu, 30 Oct 2008 01:21:15 GMT


 I am surprised you got that far. I thought that javax.imageio was not part
of Android.
You should be able to do what you want like this (pseudo code):

inputstream = url.openStream()
bitmap = BitmapFactory.decodeStream(inputstream)

Using the url
 http://chart.apis.google.com/chart?cht=p& ;chd=t:37,0,50,12,1,0,0&chs=300x200
worked, but your longer posted one did not work then. I have not
investigated this further, might have to do with some of the special chars
not correctly encoded.

HTH
Ludwig

2008/10/29 AlBasha <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. ListView with sections from a SINGLE Cursor



No, just cache it.

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 

2. Correct way to set up buffer for glReadPixels?

Hi,
What is the correct way to set up a buffer for the return data for
gl.glReadPixels? Does it have to be a direct buffer or is simply
wrapping an integer array ok (with IntBuffer.wrap)? I have seen both
used by various people in online examples.

I am currently wrapping an integer array and it works fine - except on
one particular phone manufacturer (Sony) on which apparently the data
returned is sometimes corrupt - and I am wondering if this might be
the cause?

-- 

3. ListView with sections from a SINGLE Cursor

4. Preparing sd card forever

5. Bitmaps and OutOfMemoryError: Best Practices needed

6. Run android apps on Linux natively

7. logcat buffer size