Shared image cropped

0

I have a basic problem that I can not solve. I try to share an image that was saved from a screen, the problem is that this image is saving cut off. It is intermittent .... the tests work perfectly on some devices with the purest android type (Motorola) and in others the short image. The images vary in size, since they are fiscal coupons. At some point the images may have high lengths, but this was never a problem.

If anyone can give a light, thank you! Vlw!

w = findViewById(R.id.webView);
w.setPadding(0, 0, 0, 0);
w.setInitialScale(getScale());


public void saveBitmap(Bitmap bitmap) {

    SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH);
    String cDateTime = dateFormat.format(new Date());

    FileOutputStream fos = null;
    File imagePath = new File("/sdcard/" +cDateTime+".jpg");
    try {
        fos = new FileOutputStream(imagePath);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
        String imgBitMap = MediaStore.Images.Media.insertImage(getApplicationContext().getContentResolver(),bitmap, "Cupom", null);
        //fos.flush();
        fos.close();
        Toast.makeText(con,imagePath.getAbsolutePath()+"",Toast.LENGTH_SHORT).show();

        Uri imgUrl = Uri.parse(imgBitMap);
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("*/*");

        share.putExtra(Intent.EXTRA_TEXT, mMSG + nCupom);
        share.putExtra(Intent.EXTRA_STREAM, imgUrl);
        startActivity(Intent.createChooser(share, "Enviar cupom"));

        Log.e("IMAGESAVE", "IMAGEM SALVA");
    } catch (FileNotFoundException e) {
        Log.e("GREC", e.getMessage(), e);
    } catch (IOException e) {
        Log.e("GREC", e.getMessage(), e);
    }
}



public static Bitmap loadBitmapFromView(View v, int width, int height) {
    Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.draw(c);

    return b;
}
    
asked by anonymous 15.10.2018 / 16:35

0 answers