/** * Update tag picture * * @param path * @throws IOException * @throws ActFmServiceException */ public String setTagPicture(long tagId, Bitmap bitmap) throws ActFmServiceException, IOException { if (!checkForToken()) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (bitmap.getWidth() > 512 || bitmap.getHeight() > 512) { float scale = Math.min(512f / bitmap.getWidth(), 512f / bitmap.getHeight()); bitmap = Bitmap.createScaledBitmap( bitmap, (int) (scale * bitmap.getWidth()), (int) (scale * bitmap.getHeight()), false); } bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos); byte[] bytes = baos.toByteArray(); MultipartEntity data = new MultipartEntity(); data.addPart("picture", new ByteArrayBody(bytes, "image/jpg", "image.jpg")); JSONObject result = actFmInvoker.post("tag_set_picture", data, "id", tagId, "token", token); return result.optString("url"); }