Android : sharing images sharing square image instead original proportion

on Friday, July 4, 2014


My application sharing image properly but when its reach to user it is resized to square.. Here is code for sharing..



this.share.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int i = Resources.getSystem().getDisplayMetrics().widthPixels;
Bitmap localBitmap = Bitmap.createScaledBitmap(
BitmapFactory.decodeResource(
FullImageActivity.this.getResources(),
localImageAdapter.mThumbIds[FullImageActivity.counter]
.intValue(), null), i, i, true);
new Canvas(localBitmap);
ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
localBitmap.compress(Bitmap.CompressFormat.JPEG, 90,
localByteArrayOutputStream);
try {
File localFile = File.createTempFile("sharedImage", ".jpg",
FullImageActivity.this.getExternalCacheDir());
localFile.deleteOnExit();
FileOutputStream localFileOutputStream = new FileOutputStream(
localFile);
localFileOutputStream.write(localByteArrayOutputStream
.toByteArray());
localFileOutputStream.close();
localUri2 = Uri.fromFile(localFile);
localUri1 = localUri2;
} catch (IOException localIOException) {
for (;;) {

localIOException.printStackTrace();
localUri1 = null;
}
}
Intent localIntent = new Intent("android.intent.action.SEND");
localIntent.setType("image/jpeg");
localIntent.putExtra("android.intent.extra.STREAM", localUri1);
FullImageActivity.this.startActivity(localIntent);
}
});


any changes needed in this code ? to get proper proportion..


0 comments:

Post a Comment