- 浏览: 150108 次
- 性别:
- 来自: 五指山
文章分类
最新评论
-
dengdonglin888:
qq_30221445 写道你好 请问这种数据能解吗 < ...
Simple XML -
qq_30221445:
你好 请问这种数据能解吗 <request> ...
Simple XML -
画个逗号给明天qu:
画个逗号给明天qu 写道
Android上传文件到服务器 -
画个逗号给明天qu:
...
Android上传文件到服务器 -
alranger:
我在jsp页面加上这一段代码后,问题还是存在。
解决Ext在ie9报错:不支持extjs对象的“createContextualFragment属性或方法”
转载:http://blog.csdn.net/xys289187120/article/details/6575830
android 下如果做处理图片的软件 可以调用系统的控件 实现缩放切割图片 非常好的效果 今天写了一个demo分享给大家 嘿嘿。
package cn.m15.test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class testActivity extends Activity {
public static final int NONE = 0;
public static final int PHOTOHRAPH = 1;// 拍照
public static final int PHOTOZOOM = 2; // 缩放
public static final int PHOTORESOULT = 3;// 结果
public static final String IMAGE_UNSPECIFIED = "image/*";
ImageView imageView = null;
Button button0 = null;
Button button1 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) findViewById(R.id.imageID);
button0 = (Button) findViewById(R.id.btn_01);
button1 = (Button) findViewById(R.id.btn_02);
button0.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);
startActivityForResult(intent, PHOTOZOOM);
}
});
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "temp.jpg")));
startActivityForResult(intent, PHOTOHRAPH);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == NONE)
return;
// 拍照
if (requestCode == PHOTOHRAPH) {
//设置文件保存路径这里放在跟目录下
File picture = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");
startPhotoZoom(Uri.fromFile(picture));
}
if (data == null)
return;
// 读取相册缩放图片
if (requestCode == PHOTOZOOM) {
startPhotoZoom(data.getData());
}
// 处理结果
if (requestCode == PHOTORESOULT) {
Bundle extras = data.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0 - 100)压缩文件
imageView.setImageBitmap(photo);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
public void startPhotoZoom(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
intent.putExtra("crop", "true");
// aspectX aspectY 是宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
// outputX outputY 是裁剪图片宽高
intent.putExtra("outputX", 64);
intent.putExtra("outputY", 64);
intent.putExtra("return-data", true);
startActivityForResult(intent, PHOTORESOULT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<ImageView android:id="@+id/imageID"
android:adjustViewBounds="true" android:maxWidth="50dip"
android:maxHeight="50dip" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/btn_01" android:layout_height="50dip"
android:text="相册" android:layout_width="150dip"/>
<Button android:id="@+id/btn_02" android:layout_height="50dip"
android:text="拍照" android:layout_width="150dip"/>
</LinearLayout>
发表评论
-
xUtils简介
2014-11-25 10:04 845xUtils 包含了很多实用的android工具。 xU ... -
直接拿来用!最火的Android开源项目
2014-07-25 11:01 701转 http://www.admin10000.com/d ... -
Android APK反编译详解(附图)
2014-03-28 10:56 820http://blog.csdn.net/ithomer/ar ... -
小米人
2014-02-17 17:23 686http://www.xiaomiren.net/ -
android开发之gallery 兑现滚动一张且短距离滑动实现滚动
2013-07-02 15:28 663http://www.myexception.cn/andro ... -
TextView显示插入的图片
2013-07-01 11:29 700http://orgcent.com/android-text ... -
TextView使用SpannableString设置复合文本
2013-07-01 11:29 648http://orgcent.com/android-text ... -
转:::Android TextView文字横向自动滚动(跑马灯)
2013-06-17 11:45 1513TextView实现文字滚动需要以下几个要点: 1.文字长度长 ... -
相片滤镜开源
2013-04-27 15:01 736https://github.com/daizhenjun/I ... -
android图片特效处理之模糊效果
2013-04-27 14:57 829http://blog.csdn.net/sjf0115/ar ... -
android图片处理方法(不断收集中)
2013-04-27 14:57 559http://gundumw100.iteye.com/blo ... -
Android, WindowsPhone7, IOS ,vc2010平台40多套图片滤镜开源
2013-04-27 14:56 665http://www.cnblogs.com/daizhj/a ... -
移动云存储平台
2013-04-25 16:13 906http://bmob.cn 关于Bmob 对于很多 ... -
android ExpandableListView简单应用及listview模拟ExpandableListView
2013-02-28 11:45 693http://blog.csdn.net/jj120522/a ... -
android_App集成支付宝
2013-02-28 11:43 790http://www.cnblogs.com/qianxude ... -
Android Pull Refresh View 插件
2012-12-01 12:43 847Android Pull Refresh View htt ... -
Android-TelephoneManager(转载)
2012-10-09 22:08 1347好文章齐分享。原文地址:http://blog.si ... -
android 开源 listview separato
2012-08-27 22:51 665http://code.google.com/p/androi ... -
fragment开源项目 学习
2012-08-13 12:02 929https://github.com/tisa007/Andr ... -
Fragment学习
2012-08-13 11:53 670http://www.eoeandroid.com/threa ...
相关推荐
应开发需要,不想调用第三方库实现功能。调用系统相机拍照,系统相册进行多选。注意多选照片时要长按一张图片变为多选。
android studio 调用摄像头拍照或选择相册照片,拿到图片并存储图片
应开发需要,不想调用第三方库实现功能。调用系统相机拍照,系统相册进行多选。注意多选照片时要长按一张图片变为多选。
64位机进行C#二次开发调用DLL(使用PCOMM控件)实现方法
拍照或者从相册中选择图片后,我们都可以直接或间接的得到Uri或源文件。 通过`imageView.setImageUri(uri)`不会引发图片方向不正确的问题。 但是通过`BitmapFactory.decodeFile();`将源文件解析成Bitmap后再...
Android 调用系统相机/相册 获取照片 在照片上添加文字水印
LiuZhenHong.Controls 是对VS自带控件的补充和扩展,为您进行简单的桌面应用程序开发提供帮助。 重点推荐: LiuZhenHong.Controls.WFNew目录主推的控件有: 1.DockPanelManager浮动面板控件; 2.RibbonControl...
【TakePicture】项目分为两大部分...实测:android 8、9、10、11、13以及鸿蒙系统有效。 机型:小米、OPPO、VIVO、华为手机。 1. 上传头像并裁剪。 2. 上传多张照片并做压缩处理,图片可实现在线预览,伸缩放大等功能。
Unity调用Android相册,获取到图片,在Unity中调用Android原生应用。
Android 调用系统相机拍照、以及相册。完成之后图片是上传到app上。没有上传到服务器,因为我没服务器测试。但项目里面有个类可以参考上传图片到服务器,我就没测试了。欢迎下载。
android 调用相机和相册,里面用了两种方式。一种是郭霖的,但不能适配小米,另一种是自己找的,亲测小米通过
在项目的开发过程我们离不开图片 而有时候需要调用本地的图片 有时候需要调用拍照图片 同时实现拍照的方法有两种 一种是调用系统拍照功能 另一种是自定义拍照功能 而本博文目前只讲解第一种方法 第二种方法后期在...
Android调用系统 拍照 相册 适配所有版本 7.0 恢复自动旋转
摄像头捕获控件(ezVidC60.ocx,ezVidCap.ocx),附VB调用源程序
一个简单的小demo ,代码简洁明朗。 点击按钮访问系统相册选取图片显示到imageview之上。
本应用可以实现调用系统的拍照和相册选择图片并剪切,同时也可以查看拍照的图片。
VB 调用 IMAGE 控件实现图像缩放的一种方法
包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。 包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python...
调用系统拍照、系统相册(图片压缩、查看原图、权限处理)
Android从相册选择图片和调用系统摄像头拍照