Android的图片剪裁和墙纸设置页面 [英] android image crop and wallpaper settings page
问题描述
我想实现动态壁纸在那里用户将可以在手机桌面上设置自己的照片。
I would like to implement live wallpaper where user will be able to setup own photo on the phone desktop.
现在,我已经成功地实现的逻辑在那里用户可以从Android图库或相机本身裁剪的任何照片。
Right now I have successfully implemented logic where user can crop any photo from android gallery or camera itself.
在动态壁纸设置页面我想实现裁剪照片preVIEW。为此,我已经实现SelectImage preference
On the live wallpaper settings page I'd like to implement cropped photo preview. For this purpose, I have implemented SelectImagePreference
public class SelectImagePreference extends Preference {
public SelectImagePreference(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public SelectImagePreference(Context context, AttributeSet attributeSet, int paramInt) {
super(context, attributeSet, paramInt);
setLayoutResource(R.layout.select_image_preference);
}
}
与布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:attr/theme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:listPreferredItemHeight"
android:paddingRight="?android:scrollbarSize" >
<ImageView
android:id="@+id/picture"
android:layout_width="200px"
android:layout_height="250px"
android:layout_margin="5dp"
android:background="@drawable/pic_border"
android:contentDescription="@string/picture" />
</LinearLayout>
在在的onActivityResult方法我WallpaperSettings活动我试图返回的位图设置为我的ImageView
In my WallpaperSettings activity in onActivityResult method I'm trying to set the returned Bitmap to my ImageView
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
return;
} else if (requestCode == PICK_CROP) {
try {
Bundle extras = data.getExtras();
Bitmap croppedPicture = extras.getParcelable("data");
File saveFilePath = FileUtils.createNewFile(this, FOLDER, FileUtils.getUniqueFileName(CROPPED_IMAGE_PREFIX, CROPPED_IMAGE_EXTENSION));
FileOutputStream out = new FileOutputStream(saveFilePath);
croppedPicture.compress(Bitmap.CompressFormat.JPEG, 100, out);
saveCroppedImageUrl(saveFilePath.getAbsolutePath());
ImageView pictureView = (ImageView) findViewById(R.id.picture);
pictureView.setImageBitmap(croppedPicture);
} catch (Exception e) {
e.printStackTrace();
}
}
在我的三星注2 preVIEW图为从10〜1也许时间。
On my Samsung Note 2 preview picture shows maybe 1 time from ~10.
我敢肯定存在于磁盘上的图像和位图不为空。如何解决这个问题?谢谢
I'm sure that picture exists on the disk and Bitmap is not null. How to solve this issue ? Thanks
推荐答案
看看这个壁纸幻灯片源$ C $ C:
Take a look to this wallpaper slideshow source code:
这篇关于Android的图片剪裁和墙纸设置页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!