當前位置: 首頁>>代碼示例>>Java>>正文


Java CropImage類代碼示例

本文整理匯總了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);
    }
 
開發者ID:multidots,項目名稱:android-app-common-tasks,代碼行數:12,代碼來源:CropImageActivity.java

示例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);
    }
 
開發者ID:multidots,項目名稱:android-app-common-tasks,代碼行數:12,代碼來源:Common.java

示例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);
}
 
開發者ID:snowdream,項目名稱:android-wallpaper,代碼行數:32,代碼來源:ImagePagerActivity.java

示例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;
            }
        }
    }
 
開發者ID:multidots,項目名稱:android-app-common-tasks,代碼行數:46,代碼來源:PickCaptureActivity.java

示例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);
}
 
開發者ID:multidots,項目名稱:android-app-common-tasks,代碼行數:50,代碼來源:CropImageActivity.java

示例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);
}
 
開發者ID:snowdream,項目名稱:android-wallpaper,代碼行數:47,代碼來源:ImagePagerActivity.java

示例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);
	}
 
開發者ID:Pi-Developers,項目名稱:Pi-Locker,代碼行數:13,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:Pi-Developers,項目名稱:Pi-Locker,代碼行數:49,代碼來源:MainActivity.java


注:本文中的eu.janmuller.android.simplecropimage.CropImage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。