Titanium Android模块:裁剪,旋转,调整大小...图像

时间:2016-05-20 08:44:34

标签: android appcelerator-titanium appcelerator-alloy

你知道一个允许编辑,旋转,调整大小......图像的Titanium Android模块吗?

Android resize image

1 个答案:

答案 0 :(得分:1)

这是camera.action.CROP:

//STARTS CROPPING INTENT
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(Uri.fromFile(savedPicture), "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("return-data", true);
startActivityForResult(cropIntent, CROP_PICTURE);

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data)
{
 super.onActivityResult(requestCode, resultCode, data);
 if (requestCode == CROP_PICTURE)
   {
    // SAVE PICTURE TO FILESYSTEM
    Bundle extras = data.getExtras();
    Bitmap croppedPicture = extras.getParcelable("data");
    File pictureFolder = RouterApplication.getInstance().getPictureDirectory();
    File picture = null;
    FileOutputStream fOut = null;
    try
     {
      picture = new File(pictureFolder, "a.jpg");

      if (croppedPicture != null)
       {
        fOut = new FileOutputStream(picture);
        croppedPicture.compress(Bitmap.CompressFormat.JPEG, 90, fOut);

       }
     }
    catch (FileNotFoundException e)
     {
      e.printStackTrace();
     }
   }