代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
surfaceview拍照加时间彩印
作者:
/ 发布于
2014/10/21
/
506
package com.dgchina.activity; import com.dgchina.camera.CameraInterface; import com.dgchina.camera.CameraInterface.CamOpenOverCallback; import com.dgchina.preview.*; import com.dgchina.util.DisplayUtil; import com.example.playcamera.R; import android.app.Activity; import android.graphics.Point; import android.os.Bundle; import android.view.Menu; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.view.Window; import android.view.WindowManager; import android.widget.Button; public class CameraActivity extends Activity implements CamOpenOverCallback { private static final String TAG = "yanzi"; CameraSurfaceView surfaceView = null; Button shutterBtn; float previewRate = -1f; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread openThread = new Thread(){ @Override public void run() { // TODO Auto-generated method stub CameraInterface.getInstance().doOpenCamera(CameraActivity.this); } }; openThread.start(); //去掉标题 requestWindowFeature(Window.FEATURE_NO_TITLE); //设置全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); initUI(); initViewParams(); shutterBtn.setOnClickListener(new BtnListeners()); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. // getMenuInflater().inflate(R.menu.camera, menu); return true; } private void initUI(){ surfaceView = (CameraSurfaceView)findViewById(R.id.camera_surfaceview); shutterBtn = (Button)findViewById(R.id.btn_shutter); } private void initViewParams(){ LayoutParams params = surfaceView.getLayoutParams(); Point p = DisplayUtil.getScreenMetrics(this); params.width = p.x; params.height = p.y; previewRate = DisplayUtil.getScreenRate(this); //默认全屏的比例预览 surfaceView.setLayoutParams(params); //手动设置拍照ImageButton的大小为120dip×120dip,原图片大小是64×64 // LayoutParams p2 = shutterBtn.getLayoutParams(); // p2.width = DisplayUtil.dip2px(this, 80); // p2.height = DisplayUtil.dip2px(this, 80);; // shutterBtn.setLayoutParams(p2); } @Override public void cameraHasOpened() { // TODO Auto-generated method stub SurfaceHolder holder = surfaceView.getSurfaceHolder(); CameraInterface.getInstance().doStartPreview(holder, previewRate); } private class BtnListeners implements OnClickListener{ @Override public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case R.id.btn_shutter: //CameraInterface.getInstance().doTakePicture(); break; default:break; } } } @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { //触摸屏幕时刻 case MotionEvent.ACTION_DOWN: CameraInterface.getInstance().doTakePicture(); // Toast.makeText(MainActivity.this,"点击啦!",Toast.LENGTH_LONG).show(); break; //触摸并移动时刻 case MotionEvent.ACTION_MOVE: //Toast.makeText(MainActivity.this,"移动中!",Toast.LENGTH_LONG).show(); break; //终止触摸时刻 case MotionEvent.ACTION_UP: break; } return super.onTouchEvent(event); } }
试试其它关键字
加时间
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
贡献的其它代码
Label
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3