-1

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

Android 调整图片大小

4

1 回答 1

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();
     }
   }
于 2016-05-20T08:49:56.703 回答