1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
private void transferImage(String from,String imageName, int progr) throws IOException {
try {
// transforming image into byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap1.compress(Bitmap.CompressFormat.JPEG, 25, bos);
byte[] bitmapdata = bos.toByteArray();
// base64 encoding of the bytes in a string
String bos1 = Base64.encodeBytes(bitmapdata);
// prepare request for server
postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("type", "photo"));
postParameters.add(new BasicNameValuePair("image", bos1));
postParameters.add(new BasicNameValuePair("name", imageName));
response = CustomHttpClient.executeHttpPost(Server.getPHPdirectory() + "nomFichier.php", postParameters);
/*
gestions des retour du serveurs
*/
bitmapdata = null;
//imgTaken = null;
bos = null;
System.gc();
} catch (Exception e) {
e.printStackTrace();
}
} |
Partager