- 浏览: 11781362 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
笨蛋咯:
获取不到信息?
C#枚举硬件设备 -
guokaiwhu:
能把plan的数据结构图画出来,博主的耐心和细致令人佩服。
PostgreSQL服务过程中的那些事二:Pg服务进程处理简单查询五:规划成plantree -
gao807877817:
学习
BitmapFactory.Options详解 -
GB654:
楼主,我想问一下,如何在创建PPT时插入备注信息,虽然可以解析 ...
java转换ppt,ppt转成图片,获取备注,获取文本 -
jpsb:
多谢 ,不过我照搬你的sql查不到,去掉utl_raw.cas ...
关于oracle中clob字段查询的问题
android图像处理系统框架
图像处理框架的功能简介:
有TextView、ImageView和Button三种控件
2.功能:
2.1 显示:系统初始化时,显示Lenna图像
2.2 打开图像:Open按钮完成打开图像功能。点击Open按钮,用户可以选择媒体库中的图像;
2.3 处理图像:Process按钮。当点击时,跳转到一个算法选择的Activity,根据用户的选择,系统开始处理图像;
2.4 保存图像:Save按钮。将当前显示的图像保存到原图像的路径,即替换原图像。
2.5 拍照功能:Camera按钮。用户可以打开摄像头,将拍照的图像作为素材。
2.6 截图功能:Screen按钮。点击按钮,将当前用户的界面截取下来,作为拍照的素材。
2.7 触摸功能:在ImageView区域触摸,当用户点击图像时,图像由‘原大小’变为‘适合屏幕’或相反。向上滑动,显示系统的lenna图像。向右滑动,显示上一幅图像。向下滑动,显示原图像。
作者:郑海波 2012-08-12 Email:zhb931706659@126.com
有TextView、ImageView和Button三种控件
2.功能:
2.1 显示:系统初始化时,显示Lenna图像
2.2 打开图像:Open按钮完成打开图像功能。点击Open按钮,用户可以选择媒体库中的图像;
2.3 处理图像:Process按钮。当点击时,跳转到一个算法选择的Activity,根据用户的选择,系统开始处理图像;
2.4 保存图像:Save按钮。将当前显示的图像保存到原图像的路径,即替换原图像。
2.5 拍照功能:Camera按钮。用户可以打开摄像头,将拍照的图像作为素材。
2.6 截图功能:Screen按钮。点击按钮,将当前用户的界面截取下来,作为拍照的素材。
2.7 触摸功能:在ImageView区域触摸,当用户点击图像时,图像由‘原大小’变为‘适合屏幕’或相反。向上滑动,显示系统的lenna图像。向右滑动,显示上一幅图像。向下滑动,显示原图像。
部分代码展示:
布局文件:
<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout_bg" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- 头部 --> <RelativeLayout android:id="@+id/MyLayout_top" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="25dp" android:layout_alignParentTop="true" android:gravity="center"> <TextView android:id="@+id/ImagePath" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FF00ff00" android:text="ImageProcess" /> </RelativeLayout> <!-- 底部 --> <RelativeLayout android:id="@+id/MyLayout_bottom" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:gravity="center"> <!-- 底部第一个横条 --> <LinearLayout android:id="@+id/MyLayout_bottom1" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="40dp" android:layout_alignParentTop="true"> <Button android:id="@+id/SelectBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Open" /> <Button android:id="@+id/processBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Process" /> <Button android:id="@+id/SaveBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Save" /> <Button android:id="@+id/CameraBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Camera" /> <Button android:id="@+id/ScreenShotBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Screen" /> <Button android:id="@+id/AboutBtn" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="About" /> </LinearLayout> <!-- 底部第二个横条 --> <LinearLayout android:id="@+id/MyLayout_bottom2" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="20dp" android:background="#DFDFDF" android:layout_alignParentBottom="true" android:gravity="center"> <TextView android:id="@+id/AboutTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="zhb931706659@126.com" /> </LinearLayout> </RelativeLayout> <!-- 中部 --> <RelativeLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@id/MyLayout_bottom" android:layout_below="@id/MyLayout_top" android:background="#EFDFDF" android:gravity="center"> <ImageView android:id="@+id/imageshow" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </RelativeLayout> </RelativeLayout>
主Activity代码
package com.example.njupt.zhb.imageprocesssystem; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Bitmap.CompressFormat; import android.graphics.Rect; import android.view.Menu; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class SystemMain extends Activity implements OnTouchListener { private Button selectImgBtn; private Button selectAlgBtn; private Button aboutBtn; private Button saveBtn; private Button shotScrBtn; private Button cameraBtn; private TextView filepathView; private TextView aboutView; private OnClickListener seleImgBtnListener=null; private OnClickListener seleAlgBtnListener=null; private OnClickListener aboutBtnListener=null; private OnClickListener saveBtnListener=null; private OnClickListener shotScrBtnListener=null; private OnClickListener cameraBtnListener=null; private static int RESULT_LOAD_IMAGE = 123; private static int SystemCapture=125; private String picturePath=null; private Bitmap myBitmap; private Bitmap displayBitmap; private Bitmap preBitmap; private ImageView myImageView; private ImageProcess myImageProcess=new ImageProcess(); private static final String DYNAMICACTION_Broadcast = "Broadcast.njupt.zhb.selectAlg"; float Touch_x1=0;float Touch_y1=0; float Touch_x2=0;float Touch_y2=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("ImageProcessing Made by ZhengHaibo"); setContentView(R.layout.activity_system_main); seleImgBtnListener= new View.OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_LOAD_IMAGE); } }; seleAlgBtnListener=new OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(SystemMain.this,SelectAlgActivity.class); startActivity(intent); } }; saveBtnListener=new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub SaveBitmapToJpegFile(); } }; aboutBtnListener=new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent=new Intent(SystemMain.this,ActivityAbout.class); startActivity(intent); } }; shotScrBtnListener=new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub preBitmap=myBitmap; myBitmap=ShotScreentoBitmap(null); ShowImage(myBitmap); } }; cameraBtnListener=new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, SystemCapture); } }; SetControl(); ShowImage(null); } private void SetControl(){ selectAlgBtn=(Button)findViewById(R.id.processBtn); selectImgBtn=(Button)findViewById(R.id.SelectBtn); saveBtn=(Button)findViewById(R.id.SaveBtn); aboutBtn=(Button)findViewById(R.id.AboutBtn); shotScrBtn=(Button)findViewById(R.id.ScreenShotBtn); cameraBtn=(Button)findViewById(R.id.CameraBtn); filepathView=(TextView)findViewById(R.id.ImagePath); aboutView=(TextView)findViewById(R.id.AboutTextView); myImageView=(ImageView)findViewById(R.id.imageshow); selectAlgBtn.setOnClickListener(seleAlgBtnListener); selectImgBtn.setOnClickListener(seleImgBtnListener); saveBtn.setOnClickListener(saveBtnListener); aboutBtn.setOnClickListener(aboutBtnListener); shotScrBtn.setOnClickListener(shotScrBtnListener); cameraBtn.setOnClickListener(cameraBtnListener); myImageView.setOnTouchListener(this); IntentFilter filter_dynamic = new IntentFilter(); filter_dynamic.addAction(DYNAMICACTION_Broadcast); registerReceiver(dynamicReceiver, filter_dynamic); } // 2 自定义动态广播接收器,内部类,接收选择的算法 private BroadcastReceiver dynamicReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(DYNAMICACTION_Broadcast)){ String seleFlag = intent.getStringExtra("selectFlag"); int ch=Integer.parseInt(seleFlag); switch(ch){ case 0: ShowImage(myImageProcess.brighten(10, myBitmap)); break; case 1: ShowImage(myImageProcess.averageFilter(3,3,myBitmap)); break; case 2: ShowImage(myImageProcess.averageFilter(3,3,myBitmap)); break; default: Toast.makeText(SystemMain.this, "Wrong!", Toast.LENGTH_SHORT).show(); break; } Toast.makeText(SystemMain.this, "Processing finished!", Toast.LENGTH_SHORT).show(); } } }; private Bitmap FilesToBitmap(String filename){ Bitmap temp=null; if(filename!=null){ File imageFile = new File(filename); if (imageFile.exists()) { // Load the image from file temp = BitmapFactory.decodeFile(filename); } } return temp; } public void ShowImage(Bitmap bitmap){ if (bitmap!=null) { myImageView.setImageBitmap(bitmap); displayBitmap=bitmap; } else { bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.lenna); myImageView.setImageBitmap(bitmap); myBitmap=bitmap; preBitmap=bitmap; displayBitmap=bitmap; picturePath=null; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); picturePath = cursor.getString(columnIndex); cursor.close(); filepathView.setText(picturePath); //imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath)); preBitmap=myBitmap; myBitmap=FilesToBitmap(picturePath); ShowImage(myBitmap); } if(requestCode==SystemCapture&&resultCode == RESULT_OK && null != data){ preBitmap=myBitmap; myBitmap = (Bitmap)data.getExtras().get("data"); ShowImage(myBitmap); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_system_main, menu); return true; } @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if(v.getId()==R.id.imageshow){ if(event.getAction()==MotionEvent.ACTION_DOWN){ Touch_x1=event.getX(); Touch_y1=event.getY(); //String posString="pos=("+Touch_x1+","+Touch_y1+",)"; //Toast.makeText(SystemMain.this,posString,Toast.LENGTH_SHORT).show(); } if(event.getAction()==MotionEvent.ACTION_UP){ Touch_x2=event.getX(); Touch_y2=event.getY(); //String posString="pos=("+Touch_x2+","+Touch_y2+",)"; //Toast.makeText(SystemMain.this,posString,Toast.LENGTH_SHORT).show(); float temp_x=Math.abs(Touch_x1-Touch_x1); float temp_y=Math.abs(Touch_y1-Touch_y2); if (temp_x<=1&&temp_y<=1) {//视为没有移动 LayoutParams para=myImageView.getLayoutParams(); if(para.height==LayoutParams.FILL_PARENT){ para.height=LayoutParams.WRAP_CONTENT; }else{ para.height=LayoutParams.FILL_PARENT; } myImageView.setLayoutParams(para); } if(temp_x>=temp_y){ if (Touch_x1>=Touch_x2) {//向左滑动 //ShowImage(displayBitmap); } else{//向右滑动 aboutView.setText("上一幅图像"); ShowImage(preBitmap); } } else{ if (Touch_y1>=Touch_y2) {//向上滑动 aboutView.setText("Lenna图像"); ShowImage(null); } else{//向下滑动 aboutView.setText("原图像"); ShowImage(myBitmap); } } } } return true; } public void SaveBitmapToJpegFile(){ try { String outputPath=null; if(picturePath==null){ File outputDirectory = new File("/sdcard"); String outputFile = "lennaFromSystem.jpg"; outputPath = outputDirectory.toString() + "/" + outputFile; } else { outputPath=picturePath; } int quality = 75; FileOutputStream fileOutStr = new FileOutputStream(outputPath); BufferedOutputStream bufOutStr = new BufferedOutputStream(fileOutStr); displayBitmap.compress(CompressFormat.JPEG, quality, bufOutStr); bufOutStr.flush(); bufOutStr.close(); String tips="file have save as:"+outputPath; Toast.makeText(SystemMain.this,tips,Toast.LENGTH_SHORT).show(); aboutView.setText(tips); } catch (FileNotFoundException exception) { Toast.makeText(SystemMain.this,exception.toString(), Toast.LENGTH_SHORT).show(); //Log.e("debug_log", exception.toString()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private Bitmap ShotScreentoBitmap(Activity activity) { Bitmap resultBitmap=null; //View是你需要截图的View if (activity==null) { activity=(Activity)this; } View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); resultBitmap = view.getDrawingCache(); //获取状态栏高度 Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; System.out.println(statusBarHeight); //获取屏幕长和高 int width = activity.getWindowManager().getDefaultDisplay().getWidth(); int height = activity.getWindowManager().getDefaultDisplay().getHeight(); Bitmap b = Bitmap.createBitmap(resultBitmap, 0, statusBarHeight, width, height - statusBarHeight); view.destroyDrawingCache(); return b; } }
源代码下载地址:(http://download.csdn.net/detail/nuptboyzhb/4494401)
转载请声明:http://write.blog.csdn.net/postedit/7857366
相关推荐
android图像处理系统框架1.2版
Android平台图像处理软件框架的研究与设计,讲述了在android平台下进行图像处理的开发
计算机视觉项目课设:android人脸识别项目 使用opencv作为基础图像处理框架 计算机视觉项目课设:android人脸识别项目 使用opencv作为基础图像处理框架 计算机视觉项目课设:android人脸识别项目 使用opencv作为基础...
Android平台图像处理软件框架的研究与设计
Android平台图像处理软件框架的开发与设计.pdf
(2) 注解模块:android中的ioc框架,完全注解方式就可以进行UI绑定和事件绑定。无需findViewById和setClickListener等。 (3) 网络模块:通过httpclient进行封装http数据请求,支持ajax方式加载,支持下载、上传...
通过利用GPU上的着色器来加速Android设备上的图像处理的框架。_Java_下载.zip
1、该资源内项目代码经过严格调试,下载即用确保可以运行! 2、该资源适合计算机相关专业(如计科、人工智能、大数据、数学、电子...基于android的人脸识别项目使用opencv作为基础图像处理框架源码(计算机课设).zip
在安卓的开发中肯定避免不了对图像的处理,图像的处理最大的问题就是会出现OOM,为了找到一个更好效率更高的图形处理框架,本小白试了几个开源框架,最后剩下这些个人认为比较好用的~~~
【项目资源】:图像处理。包含前端、后端、移动开发、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源等各种技术项目的源码。包括C++、Java、python、web、C#、EDA等项目的源码。 【适用人群】:...
使用WebView组件链接图片JSON数据,下载图片。 改变图片信息的透明度。 配套书籍:《Android权威编程指南》(第二版)第29章内容
段,Android 图像处理篇,Android_CTS测试研,GoogleMaps基础开发教程,Android_GPS架构分析,android_JNI编程_一些技 巧,android_jni操作指南,Android_NDK开发实例,Android_RIL层剖析(官方翻译),Android2.2+API+中文...
段,Android 图像处理篇,Android_CTS测试研,GoogleMaps基础开发教程,Android_GPS架构分析,android_JNI编程_一些技 巧,android_jni操作指南,Android_NDK开发实例,Android_RIL层剖析(官方翻译),Android2.2+API+中文...