我只是裁剪图像以获取其中的一部分。但是Android将返回的图像设置为墙纸。为什么?我跟踪 android 代码,在 Gallery3D 应用程序(com.cooliris)中,我发现了这个:
// TODO: A temporary file is NOT necessary
// The CropImage intent should be able to set the wallpaper directly
// without writing to a file, which we then need to read here to write
// it again as the final wallpaper, this is silly
mTempFile = getFileStreamPath("temp-wallpaper");
mTempFile.getParentFile().mkdirs();
int width = getWallpaperDesiredMinimumWidth();
int height = getWallpaperDesiredMinimumHeight();
intent.putExtra("outputX", width);
intent.putExtra("outputY", height);
intent.putExtra("aspectX", width);
intent.putExtra("aspectY", height);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempFile));
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
// TODO: we should have an extra called "setWallpaper" to ask CropImage
// to set the cropped image as a wallpaper directly. This means the
// SetWallpaperThread should be moved out of this class to CropImage
请关注最后几行,TODO。它告诉作物意图将完成设置工作。好吧,我根本不需要它。那么,如何在不设置壁纸的情况下裁剪图像?谢谢!