I have a ImageView
that has a drawable that was edited while using the app, wanted to take this final version of the edition and send it via E-mail, Bluetooth, etc.
The way I'm doing it, when I send it by email for example, I get information that the image size is 0 bytes, that is, I can not make submissions.
I'm trying this way:
drawingView.setDrawingCacheEnabled(true);
Bitmap bitmapp = drawingView.getDrawingCache();
resultView.setImageBitmap(bitmapp); //Aqui está a imagem que quero enviar
Bitmap bitmap = bitmapp;
bitmap = scaleDownBitmap(drawableToBitmap(resultView.getDrawable()), 100, resultView.getContext());// estou trabalhando com o bitmap da resultView
Bundle param = new Bundle();
param.putParcelable("BITMAP", bitmap);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtras(param); //Estou add ele em uma Intent
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(saveImage().getAbsolutePath()));
startActivity(Intent.createChooser(share, "Share Image"));
saveImage method:
public File saveImage() {
int imageNum = 0;
File imagesFolder = new File(Environment.getExternalStorageDirectory()+File.separator+"DCIM", "@string/app_name");
imagesFolder.mkdirs();
String fileName = "imageKL_" + String.valueOf(imageNum) + ".jpg"; //ALTERAR PARA PNG ! ! !
File output = new File(imagesFolder, fileName);
while (output.exists()){
imageNum++;
fileName = "imageKL_" + String.valueOf(imageNum) + ".jpg"; //ALTERAR PARA PNG ! ! !
output = new File(imagesFolder, fileName);
}
try {
drawingView.setDrawingCacheEnabled(true);
Bitmap bitmapp = drawingView.getDrawingCache();
resultView.setImageBitmap(bitmapp);
Bitmap bitmap = bitmapp;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
FileOutputStream fo = new FileOutputStream(output);
fo.write(bytes.toByteArray());
fo.flush();
fo.close();
MediaScannerConnection.scanFile(EditImage.this, new String[]{output.getAbsolutePath()}, null, null);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return output;
}
I appreciate the attention and if anyone knows or has any idea how to solve this problem, every tip is welcome!