裁剪图片中遇到问题,怎么解决?

news/2024/6/27 3:27:50 标签: python, 移动开发

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

问题代码:

Intent cropIntent = new Intent("com.android.camera.action.CROP");
                        cropIntent.setType("image/*");
                        cropIntent.putExtra("crop", "true");
                        cropIntent.putExtra("aspectX", 1);
                        cropIntent.putExtra("aspectY", 1);
                        cropIntent.putExtra("outputX", Conf.getInt("IMAGE_WIDTH"));
                        cropIntent.putExtra("outputY", Conf.getInt("IMAGE_HEIGHT"));
                        cropIntent.putExtras(extras);
                        startActivityForResult(cropIntent, CROP_REQUEST_CODE);

这是4.3以前用的方法,那自从升级到4.4以后,该如何使用呢?

try {
    int aspectX = 750;
    int aspectY = 1011;

    Intent intent = new Intent(this, CropImage.class);
    intent.putExtra(CropImage.IMAGE_PATH, path);

    intent.putExtra(CropImage.SCALE, true);

    intent.putExtra("aspectX", aspectX);
    intent.putExtra("aspectY", aspectY);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath)));

    startActivityForResult(intent, CROP);
    
    }catch (ActivityNotFoundException anfe) {
    
    String errorMessage = "Your device doesn't support the crop action!";
    Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
    toast.show();
    
    }





转载于:https://my.oschina.net/u/1244156/blog/221773


http://www.niftyadmin.cn/n/1798848.html

相关文章

POJ 1847 最短路问题 dijkstra算法的实现

首先自己练习了一下实现dijkstra算法,可以把dj算法与prim算法对比记忆,要理解pre数组、min数组、V标记数组的含义! //单源最短路径,dijkstra算法,邻接阵形式,复杂度O(n^2)//求出源s到所有点的最短路经,传入图的顶点数n,(有向)邻接矩阵mat//返回到各点最…

leetcode(101):Symmetric Tree

题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 对于题目的分析:这个题目要求判断给定的这棵树是不是关于根节点对称。对于根节点而言,首先需要判断根节点是不是为None形式&#…

消除云界限——NetApp更新高端存储

云本身就是无形的、灵动的。但是借用了“云”概念的计算却非要分清到底是公有、私有还是混合。 如今,人们又在想方设法消除公有云、私有云和混合云之间的界限,让数据和应用能够在“自由云域”中畅行。无论是公有云、私有云还是混合云,它们对于…

linux上部署nodejs

linux上部署nodejs 环境:# lsb_release -aLSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarchDistributor ID: CentOSDescript…

leetcode(617):Merge Two Binary Trees

题目要求: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two no…

POJ 1247 数组首尾求和判定相等 枚举法

此题把题意弄懂后就很容易&#xff0c;S顺时针走&#xff0c;E逆时针走&#xff0c;确定一个分割点该处两人相遇时途经的客人数之和相等&#xff0c;直接枚举。 #include <iostream> using namespace std; //s顺时针走&#xff0c;e逆时针走&#xff0c;问他们在哪里相遇…

开源 免费 java CMS - FreeCMS1.8 互动信件

2019独角兽企业重金招聘Python工程师标准>>> 项目地址&#xff1a;http://code.google.com/p/freecms/ 互动信件 1. 部门信件管理 部门信件指接收人为部门的信件,从左侧管理菜单点击部门信件进入。 admin可以管理所有部门信件&#xff0c;其他用户可以管理自己…

leetcode(669):Trim a Binary Search Tree

题目&#xff1a;Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R > L). You might need to change the root of the tree, so the result should return the new root of the tr…