本文整理汇总了Java中eu.janmuller.android.simplecropimage.CropImage类的典型用法代码示例。如果您正苦于以下问题:Java CropImage类的具体用法?Java CropImage怎么用?Java CropImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CropImage类属于eu.janmuller.android.simplecropimage包,在下文中一共展示了CropImage类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCropImage
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
private void startCropImage() {
Intent intent = new Intent(this, CropImage.class);
intent.putExtra(CropImage.IMAGE_PATH, mFileTemp.getPath());
intent.putExtra(CropImage.SCALE, true);
intent.putExtra(CropImage.ASPECT_X, 1);//width
intent.putExtra(CropImage.ASPECT_Y, 1);//hight
startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);
}
示例2: startCropImage
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
public static void startCropImage(Context context, String path, @SuppressWarnings("SameParameterValue") int requestCode, @SuppressWarnings("SameParameterValue") int aspectX) {
Intent intent = new Intent(context, CropImage.class);
intent.putExtra(CropImage.IMAGE_PATH, path);
intent.putExtra(CropImage.SCALE, true);
intent.putExtra(CropImage.ASPECT_X, aspectX);
intent.putExtra(CropImage.ASPECT_Y, 1);
((Activity) context).startActivityForResult(intent, requestCode);
}
示例3: onActivityResult
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
return;
}
Bitmap bitmap = null;
switch (requestCode) {
case REQUEST_CODE_CROP_IMAGE:
String path = data.getStringExtra(CropImage.IMAGE_PATH);
if (path == null) {
return;
}
bitmap = BitmapFactory.decodeFile(path);
if (bitmap != null && !bitmap.isRecycled()) {
try {
setWallpaper(bitmap);
Toast.makeText(this, "Set Successful", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Set Failed", Toast.LENGTH_SHORT).show();
}
}
break;
default:
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
示例4: onActivityResult
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 101:
vvVideo.setVisibility(View.GONE);
ivPreview.setVisibility(View.VISIBLE);
Common.previewCapturedImage(ivPreview);
break;
case 102:
vvVideo.setVisibility(View.VISIBLE);
ivPreview.setVisibility(View.GONE);
Common.previewVideo(vvVideo);
break;
case 103:
vvVideo.setVisibility(View.GONE);
ivPreview.setVisibility(View.VISIBLE);
Uri uri = data.getData();
Common.startCropImage(this, Common.getPath(this, uri), 105, 1);
// try {
// Bitmap bm = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
// ivPreview.setImageBitmap(bm);
// } catch (IOException e) {
// e.printStackTrace();
// }
break;
case 104:
vvVideo.setVisibility(View.VISIBLE);
ivPreview.setVisibility(View.GONE);
Uri fileUri = data.getData();
vvVideo.setVideoPath(Common.getPath(PickCaptureActivity.this, fileUri));
vvVideo.start();
break;
case 105:
String path = data.getStringExtra(CropImage.IMAGE_PATH);
File imgFile = new File(path);
if (imgFile.exists()) {
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ivPreview.setImageBitmap(myBitmap);
}
break;
}
}
}
示例5: onActivityResult
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
return;
}
Bitmap bitmap;
switch (requestCode) {
case REQUEST_CODE_GALLERY:
try {
InputStream inputStream = getContentResolver().openInputStream(data.getData());
FileOutputStream fileOutputStream = new FileOutputStream(mFileTemp);
copyStream(inputStream, fileOutputStream);
fileOutputStream.close();
if (inputStream != null) {
inputStream.close();
}
startCropImage();
} catch (Exception e) {
Log.e(TAG, "Error while creating temp file", e);
}
break;
case REQUEST_CODE_TAKE_PICTURE:
startCropImage();
break;
case REQUEST_CODE_CROP_IMAGE:
String path = data.getStringExtra(CropImage.IMAGE_PATH);
if (path == null) {
return;
}
bitmap = BitmapFactory.decodeFile(mFileTemp.getPath());
mImageView.setImageBitmap(bitmap);
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
示例6: setWallPaper
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
private void setWallPaper() {
if (pager == null || pager.getAdapter() == null
|| !(pager.getAdapter() instanceof ImagePagerAdapter)) {
return;
}
ImagePagerAdapter adapter = (ImagePagerAdapter) pager.getAdapter();
List<Image> images = adapter.getImages();
if (images == null || images.size() <= 0) {
return;
}
int pos = pager.getCurrentItem();
if (pos >= images.size()) {
return;
}
Image image = images.get(pos);
if (image == null) {
return;
}
String imageUrl = image.getUrl();
if (imageUrl == null || imageUrl == "") {
return;
}
File file = ImageLoader.getInstance().getDiscCache().get(imageUrl);
if (file == null || !file.exists() || !file.canRead()) {
return;
}
Intent intent = new Intent(this, CropImage.class);
intent.putExtra(CropImage.IMAGE_PATH, file.getPath());
intent.putExtra(CropImage.SCALE, true);
intent.putExtra(CropImage.ASPECT_X, 480);
intent.putExtra(CropImage.ASPECT_Y, 800);
startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);
}
示例7: startCropImage
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
private void startCropImage() {
Intent intent = new Intent(this, CropImage.class);
intent.putExtra(CropImage.IMAGE_PATH, mFileTemp.getPath());
intent.putExtra(CropImage.SCALE, true);
intent.putExtra(CropImage.ASPECT_X, 2);
intent.putExtra(CropImage.ASPECT_Y, 4);
startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);
}
示例8: onActivityResult
import eu.janmuller.android.simplecropimage.CropImage; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
return;
}
switch (requestCode) {
case REQUEST_CODE_GALLERY:
try {
InputStream inputStream = getContentResolver().openInputStream(data.getData());
FileOutputStream fileOutputStream = new FileOutputStream(mFileTemp);
copyStream(inputStream, fileOutputStream);
fileOutputStream.close();
inputStream.close();
startCropImage();
} catch (Exception e) {
Log.e(TAG, "Error while creating temp file", e);
}
break;
case REQUEST_CODE_TAKE_PICTURE:
startCropImage();
break;
case REQUEST_CODE_CROP_IMAGE:
String path = data.getStringExtra(CropImage.IMAGE_PATH);
if (path == null) {
return;
}
save("img", mFileTemp.getPath());
break;
}
super.onActivityResult(requestCode, resultCode, data);
}