Spero che questo sia sufficiente.
Se si utilizza php;
echo base64_encode($imgBinary); // You can get the imagebinary by using the fread and fopen methods provided by php
su Android:
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(new HttpGet(url));
HttpEntity entity = httpResponse.getEntity();
if(entity != null) {
InputStream is = entity.getContent();
byte[] decodedString = Base64.decode(convertStreamToString(is), Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
}
Questo non è probabilmente il modo più efficiente, ma dovrebbe fare il lavoro. Da lì in poi puoi costruire :)
Puoi comprimere la bitmap in un PNG dopo e salvarla. esempio:
decodedByte.compress(compressformat, quality, stream);//suported compress formats can be used like so: Bitmap.CompressFormat.PNG etc
convertStreamToString sono metodi facilmente reperibili. Fai una rapida ricerca su google o scrivi la tua.
fonte
2011-12-02 10:21:10
è il codice di risposta del server 200 ? – rekire
Sì. Ho confermato che gli URL sono validi. – Steve
Ho usato uno sniffer di pacchetti solo per essere sicuro, e le richieste di immagine sono state fatte, e viene restituita una risposta di 200 con l'immagine. – Steve