1
I own a ImageView
that has a drawable that was edited during the use of the app, wanted to take this final edition and send it by Email, Bluetooth, etc..
The way I’m doing, when I send by email for example, I get information that the image size is 0 bytes, I mean, I can’t send..
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"));
Metodo saveImage:
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 in case anyone knows or has any idea how to solve this problem, any tip is welcome!
Hello, now include the method in the question. Hug!
– CristianCotrena