源码:http://files.cnblogs.com/android100/StandardCamera2013-10-18.zip

废话不说了,就是加个seekbar,拖动的话能够调节焦距,让画面变大或缩小。下面是核心程序:

一,camera的布局文件

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical" >
  6. <TextView
  7. android:layout_width="wrap_content"
  8. android:layout_height="wrap_content"
  9. android:text="@string/BestWish"
  10. tools:context=".StandardCamera" />
  11. <RelativeLayout
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content" >
  14. <FrameLayout
  15. android:layout_width="wrap_content"
  16. android:layout_height="wrap_content" >
  17. <SurfaceView
  18. android:id="@+id/previewSV"
  19. android:layout_width="fill_parent"
  20. android:layout_height="wrap_content" />
  21. </FrameLayout>
  22. <LinearLayout
  23. android:id="@+id/zoomLayout"
  24. android:layout_width="wrap_content"
  25. android:layout_height="40dp"
  26. android:layout_centerInParent="true"
  27. android:layout_centerHorizontal="true"
  28. android:orientation="horizontal" >
  29. <TextView
  30. android:id="@+id/textView1"
  31. android:layout_width="wrap_content"
  32. android:layout_height="wrap_content"
  33. android:text="-"
  34. android:textColor="#ffffff"
  35. android:textSize="30dip"/>
  36. <SeekBar
  37. android:id="@+id/seekbar_zoom"
  38. android:layout_width="300dp"
  39. android:layout_height="wrap_content"
  40. android:layout_gravity="center_vertical"
  41. android:progressDrawable="@drawable/seekbar_style"
  42. android:thumb="@drawable/ic_launcher"
  43. android:thumbOffset="0dp" />
  44. <TextView
  45. android:id="@+id/textView2"
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content"
  48. android:text="+"
  49. android:textColor="#ffffff"
  50. android:textSize="30dip" />
  51. </LinearLayout>
  52. </RelativeLayout>
  53. <ImageButton
  54. android:id="@+id/photoImgBtn"
  55. android:layout_width="wrap_content"
  56. android:layout_height="wrap_content"
  57. android:layout_gravity="center"
  58. android:background="@drawable/photo_img_btn" />
  59. </LinearLayout>

其中里面嵌套的LinearLayout就是那个ZoomBar,最外面我用了相对布局,发现相对布局用起来还是很好用的。为了方便以后扩展,Camera的SurfaceView用的帧布局。注意SeekBar的几个参数,其中的progressDrawable是指那个横条的形状,可以直接用个图片,也可以写个xml文件。这里用的是xml,当然用图片很简单。seekbar_style.xml文件如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3. <item android:id="@android:id/background">
  4. <shape>
  5. <corners android:radius="5dip" />
  6. <gradient
  7. android:startColor="#ff9d9e9d"
  8. android:centerColor="#ff5a5d5a"
  9. android:centerY="0.75"
  10. android:endColor="#ff747674"
  11. android:angle="270"
  12. />
  13. </shape>
  14. </item>
  15. </layer-list>

下面的android:thumb是滑动的那个手柄,本来我是写了一个xml文件,名字为thumb.xml如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  3. <!-- 按下状态 -->
  4. <item android:state_focused="true" android:state_pressed="true"><shape android:shape="oval">
  5. <gradient android:angle="0" android:centerColor="#FF00FF00" android:endColor="#000000" android:gradientRadius="8" android:startColor="#FFFF0000" android:type="radial" />
  6. <size android:height="20dip" android:width="20dip"></size>
  7. </shape></item>
  8. </selector>

无奈啥也显示不出来,索性直接找了个粗糙的图片,见谅哈!

二,整个程序的主代码:

  1. package yan.guoqi.camera;
  2. import java.io.BufferedOutputStream;
  3. import java.io.File;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.util.List;
  7. import yan.guoqi.rectphoto.R;
  8. import android.app.Activity;
  9. import android.content.Context;
  10. import android.graphics.Bitmap;
  11. import android.graphics.BitmapFactory;
  12. import android.graphics.ColorMatrixColorFilter;
  13. import android.graphics.Matrix;
  14. import android.graphics.PixelFormat;
  15. import android.hardware.Camera;
  16. import android.hardware.Camera.AutoFocusCallback;
  17. import android.hardware.Camera.Parameters;
  18. import android.hardware.Camera.PictureCallback;
  19. import android.hardware.Camera.PreviewCallback;
  20. import android.hardware.Camera.ShutterCallback;
  21. import android.os.Bundle;
  22. import android.util.Log;
  23. import android.view.Display;
  24. import android.view.MotionEvent;
  25. import android.view.SurfaceHolder;
  26. import android.view.SurfaceView;
  27. import android.view.View;
  28. import android.view.View.OnClickListener;
  29. import android.view.View.OnTouchListener;
  30. import android.view.ViewGroup.LayoutParams;
  31. import android.view.Window;
  32. import android.view.WindowManager;
  33. import android.widget.ImageButton;
  34. import android.widget.SeekBar;
  35. import android.widget.SeekBar.OnSeekBarChangeListener;
  36. public class StandardCamera extends Activity implements SurfaceHolder.Callback, PreviewCallback{
  37. private static final String tag="StandardCamera";
  38. private boolean isPreview = false;
  39. private SurfaceView mPreviewSV = null; //棰勮SurfaceView
  40. private SurfaceHolder mySurfaceHolder = null;
  41. private ImageButton mPhotoImgBtn = null;
  42. private Camera myCamera = null;
  43. private Bitmap mBitmap = null;
  44. private AutoFocusCallback myAutoFocusCallback = null;
  45. boolean flag = true;
  46. private SeekBar mZoomBar = null;
  47. @Override
  48. public void onCreate(Bundle savedInstanceState) {
  49. super.onCreate(savedInstanceState);
  50. requestWindowFeature(Window.FEATURE_NO_TITLE);
  51. int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
  52. Window myWindow = this.getWindow();
  53. myWindow.setFlags(flag, flag);
  54. setContentView(R.layout.activity_rect_photo);
  55. initView();
  56. mySurfaceHolder = mPreviewSV.getHolder();
  57. mySurfaceHolder.setFormat(PixelFormat.TRANSLUCENT);
  58. mySurfaceHolder.addCallback(this);
  59. mySurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  60. myAutoFocusCallback = new AutoFocusCallback() {
  61. public void onAutoFocus(boolean success, Camera camera) {
  62. // TODO Auto-generated method stub
  63. if(success)
  64. {
  65. Log.i(tag, "myAutoFocusCallback: success...");
  66. }
  67. else
  68. {
  69. Log.i(tag, "myAutoFocusCallback: 澶辫触浜�?.");
  70. }
  71. }
  72. };
  73. //添加ZoomBar
  74. mZoomBar = (SeekBar)findViewById(R.id.seekbar_zoom);
  75. mZoomBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
  76. public void onStopTrackingTouch(SeekBar seekBar) {
  77. // TODO Auto-generated method stub
  78. }
  79. public void onStartTrackingTouch(SeekBar seekBar) {
  80. // TODO Auto-generated method stub
  81. }
  82. public void onProgressChanged(SeekBar seekBar, int progress,
  83. boolean fromUser) {
  84. // TODO Auto-generated method stub
  85. Parameters p = myCamera.getParameters();
  86. p.setZoom(progress);
  87. myCamera.setParameters(p);
  88. }
  89. });
  90. }
  91. public void initView(){
  92. mPreviewSV = (SurfaceView)findViewById(R.id.previewSV);
  93. WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
  94. Display display = wm.getDefaultDisplay();
  95. LayoutParams lpSV = mPreviewSV.getLayoutParams();
  96. lpSV.width = display.getWidth();
  97. lpSV.height = (int) ((float)display.getHeight()*0.75);
  98. mPreviewSV.setLayoutParams(lpSV);
  99. mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
  100. LayoutParams lp = mPhotoImgBtn.getLayoutParams();
  101. lp.width = 240;
  102. lp.height = 240;
  103. mPhotoImgBtn.setLayoutParams(lp);
  104. mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
  105. mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
  106. }
  107. public void surfaceChanged(SurfaceHolder holder, int format, int width,int height)
  108. {
  109. // TODO Auto-generated method stub
  110. Log.i(tag, "SurfaceHolder.Callback:surfaceChanged!");
  111. initCamera();
  112. }
  113. public void surfaceCreated(SurfaceHolder holder)
  114. {
  115. // TODO Auto-generated method stub
  116. myCamera = Camera.open();
  117. try {
  118. myCamera.setPreviewDisplay(mySurfaceHolder);
  119. Log.i(tag, "SurfaceHolder.Callback: surfaceCreated!");
  120. } catch (IOException e) {
  121. // TODO Auto-generated catch block
  122. if(null != myCamera){
  123. myCamera.release();
  124. myCamera = null;
  125. }
  126. e.printStackTrace();
  127. }
  128. }
  129. public void surfaceDestroyed(SurfaceHolder holder)
  130. {
  131. // TODO Auto-generated method stub
  132. Log.i(tag, "SurfaceHolder.Callback锛歋urface Destroyed");
  133. if(null != myCamera)
  134. {
  135. myCamera.setPreviewCallback(null);
  136. myCamera.stopPreview();
  137. isPreview = false;
  138. myCamera.release();
  139. myCamera = null;
  140. }
  141. }
  142. public void initCamera(){
  143. if(isPreview){
  144. myCamera.stopPreview();
  145. }
  146. if(null != myCamera){
  147. Camera.Parameters myParam = myCamera.getParameters();
  148. myParam.setPictureFormat(PixelFormat.JPEG);//璁剧疆鎷嶇収鍚庡瓨鍌ㄧ殑鍥剧墖鏍煎紡
  149. //List<Size> pictureSizes = myParam.getSupportedPictureSizes();
  150. //List<Size> previewSizes = myParam.getSupportedPreviewSizes();
  151. //          for(int i=0; i<pictureSizes.size(); i++){
  152. //              Size size = pictureSizes.get(i);
  153. //              Log.i(tag, "initCamera:pictureSizes: width = "+size.width+"height = "+size.height);
  154. //          }
  155. //          for(int i=0; i<previewSizes.size(); i++){
  156. //              Size size = previewSizes.get(i);
  157. //              Log.i(tag, "initCamera:鎽勫儚澶存敮鎸佺殑previewSizes: width = "+size.width+"height = "+size.height);
  158. //
  159. //          }
  160. myParam.setPictureSize(1280, 960);  //
  161. myParam.setPreviewSize(960, 720);   //
  162. //myParam.set("rotation", 90);
  163. myCamera.setDisplayOrientation(90);
  164. List<String> focuseMode = (myParam.getSupportedFocusModes());
  165. for(int i=0; i<focuseMode.size(); i++){
  166. Log.i(tag, focuseMode.get(i));
  167. if(focuseMode.get(i).contains("continuous")){
  168. myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
  169. }
  170. else{
  171. myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
  172. }
  173. }
  174. //设置mZoomBar的最大值
  175. mZoomBar.setMax(myParam.getMaxZoom());
  176. myCamera.setParameters(myParam);
  177. myCamera.startPreview();
  178. myCamera.autoFocus(myAutoFocusCallback);
  179. isPreview = true;
  180. }
  181. }
  182. ShutterCallback myShutterCallback = new ShutterCallback()
  183. {
  184. public void onShutter() {
  185. // TODO Auto-generated method stub
  186. Log.i(tag, "myShutterCallback:onShutter...");
  187. }
  188. };
  189. PictureCallback myRawCallback = new PictureCallback()
  190. {
  191. public void onPictureTaken(byte[] data, Camera camera) {
  192. // TODO Auto-generated method stub
  193. Log.i(tag, "myRawCallback:onPictureTaken...");
  194. }
  195. };
  196. PictureCallback myJpegCallback = new PictureCallback()
  197. {
  198. public void onPictureTaken(byte[] data, Camera camera) {
  199. // TODO Auto-generated method stub
  200. Log.i(tag, "myJpegCallback:onPictureTaken...");
  201. if(null != data){
  202. mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);//data鏄瓧鑺傛暟鎹紝灏嗗叾瑙f瀽鎴愪綅鍥�                myCamera.stopPreview();
  203. isPreview = false;
  204. }
  205. Matrix matrix = new Matrix();
  206. matrix.postRotate((float)90.0);
  207. Bitmap rotaBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, false);
  208. if(null != rotaBitmap)
  209. {
  210. saveJpeg(rotaBitmap);
  211. }
  212. myCamera.startPreview();
  213. isPreview = true;
  214. }
  215. };
  216. public class PhotoOnClickListener implements OnClickListener{
  217. public void onClick(View v) {
  218. // TODO Auto-generated method stub
  219. if(isPreview && myCamera!=null){
  220. myCamera.takePicture(myShutterCallback, null, myJpegCallback);
  221. }
  222. }
  223. }
  224. public void saveJpeg(Bitmap bm){
  225. String savePath = "/mnt/sdcard/rectPhoto/";
  226. File folder = new File(savePath);
  227. if(!folder.exists()) {
  228. folder.mkdir();
  229. }
  230. long dataTake = System.currentTimeMillis();
  231. String jpegName = savePath + dataTake +".jpg";
  232. Log.i(tag, "saveJpeg:jpegName--" + jpegName);
  233. //File jpegFile = new File(jpegName);
  234. try {
  235. FileOutputStream fout = new FileOutputStream(jpegName);
  236. BufferedOutputStream bos = new BufferedOutputStream(fout);
  237. //          Bitmap newBM = bm.createScaledBitmap(bm, 600, 800, false);
  238. bm.compress(Bitmap.CompressFormat.JPEG, 100, bos);
  239. bos.flush();
  240. bos.close();
  241. } catch (IOException e) {
  242. // TODO Auto-generated catch block
  243. e.printStackTrace();
  244. }
  245. }
  246. public class MyOnTouchListener implements OnTouchListener{
  247. public final  float[] BT_SELECTED=new float[]
  248. { 2, 0, 0, 0, 2,
  249. 0, 2, 0, 0, 2,
  250. 0, 0, 2, 0, 2,
  251. 0, 0, 0, 1, 0 };
  252. public final float[] BT_NOT_SELECTED=new float[]
  253. { 1, 0, 0, 0, 0,
  254. 0, 1, 0, 0, 0,
  255. 0, 0, 1, 0, 0,
  256. 0, 0, 0, 1, 0 };
  257. public boolean onTouch(View v, MotionEvent event) {
  258. // TODO Auto-generated method stub
  259. if(event.getAction() == MotionEvent.ACTION_DOWN){
  260. v.getBackground().setColorFilter(new ColorMatrixColorFilter(BT_SELECTED));
  261. v.setBackgroundDrawable(v.getBackground());
  262. }
  263. else if(event.getAction() == MotionEvent.ACTION_UP){
  264. v.getBackground().setColorFilter(new ColorMatrixColorFilter(BT_NOT_SELECTED));
  265. v.setBackgroundDrawable(v.getBackground());
  266. }
  267. return false;
  268. }
  269. }
  270. @Override
  271. public void onBackPressed()
  272. {
  273. // TODO Auto-generated method stub
  274. super.onBackPressed();
  275. StandardCamera.this.finish();
  276. }
  277. class UpdateThread implements Runnable{
  278. public void run() {
  279. // TODO Auto-generated method stub
  280. while(flag){
  281. if(myCamera!=null && isPreview)
  282. myCamera.autoFocus(myAutoFocusCallback); //鑷姩鑱氱劍
  283. myCamera.setOneShotPreviewCallback(StandardCamera.this); //onPreviewFrame閲屼細鎺ュ彈鍒版暟鎹�?           myCamera.stopPreview(); //鍋滄棰勮
  284. flag = false;
  285. try {
  286. Thread.sleep(1000);
  287. } catch (InterruptedException e) {
  288. // TODO Auto-generated catch block
  289. e.printStackTrace();
  290. }
  291. }
  292. }
  293. }
  294. public void onPreviewFrame(byte[] data, Camera camera) {
  295. // TODO Auto-generated method stub
  296. }
  297. }

需要注意的有以下几点:

1,为了让程序适用不同的手机,onCreate函数里用如下代码初始化SurfaceView的大小,避免以前写死的方法:

public void initView(){
  mPreviewSV = (SurfaceView)findViewById(R.id.previewSV);
  WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
        LayoutParams lpSV = mPreviewSV.getLayoutParams();
        lpSV.width = display.getWidth();
        lpSV.height = (int) ((float)display.getHeight()*0.75);
        mPreviewSV.setLayoutParams(lpSV);

mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
  LayoutParams lp = mPhotoImgBtn.getLayoutParams();
  lp.width = 240;
  lp.height = 240;  
  mPhotoImgBtn.setLayoutParams(lp);    
  mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
  mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
 }

2,关于ZoomBar的代码片段很简短,如下:

mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
  LayoutParams lp = mPhotoImgBtn.getLayoutParams();
  lp.width = 240;
  lp.height = 240;  
  mPhotoImgBtn.setLayoutParams(lp);    
  mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
  mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
 }
  //添加ZoomBar
  mZoomBar = (SeekBar)findViewById(R.id.seekbar_zoom);
  mZoomBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
   
   public void onStopTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
    
   }
   
   public void onStartTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
    
   }
   
   public void onProgressChanged(SeekBar seekBar, int progress,
     boolean fromUser) {
    // TODO Auto-generated method stub
    Parameters p = myCamera.getParameters();
    p.setZoom(progress);
    myCamera.setParameters(p);
   }
  });

3,在initCamera函数里,查询camera支持的聚焦模式,如果带连续视频聚焦则使用连续视频聚焦,否则使用自动聚焦:

mPhotoImgBtn = (ImageButton)findViewById(R.id.photoImgBtn);
  LayoutParams lp = mPhotoImgBtn.getLayoutParams();
  lp.width = 240;
  lp.height = 240;  
  mPhotoImgBtn.setLayoutParams(lp);    
  mPhotoImgBtn.setOnClickListener(new PhotoOnClickListener());
  mPhotoImgBtn.setOnTouchListener(new MyOnTouchListener());
 }
List<String> focuseMode = (myParam.getSupportedFocusModes());
   for(int i=0; i<focuseMode.size(); i++){
    Log.i(tag, focuseMode.get(i));
    if(focuseMode.get(i).contains("continuous")){
     myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
    }
    else{
     myParam.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    }
   }

4,同样在initCamera函数里,设置ZoomBar的最大值:
//设置mZoomBar的最大值
   mZoomBar.setMax(myParam.getMaxZoom());

后续将写专文分析Camera4.0的源码,并且模仿到自己的代码中!

Android Camera开发:给摄像头预览界面加个ZoomBar(附完整代码下载)的更多相关文章

  1. 玩转Android Camera开发(一):Surfaceview预览Camera,基础拍照功能完整demo

    杂家前文是在2012年的除夕之夜仓促完成,后来很多人指出了一些问题,琐事缠身一直没有进行升级.后来随着我自己的使用,越来越发现不出个升级版的demo是不行了.有时候就连我自己用这个demo测一些性能. ...

  2. Android Camera开发:使用GLSurfaceView预览Camera 基础拍照

    GLSurfaceView是OpenGL中的一个类,也是可以预览Camera的,而且在预览Camera上有其独到之处.独到之处在哪?当使用Surfaceview无能为力.痛不欲生时就只有使用GLSur ...

  3. 使用DevExpress的PdfViewer实现PDF打开、预览、另存为、打印(附源码下载)

    场景 Winform控件-DevExpress18下载安装注册以及在VS中使用: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/1 ...

  4. Android 摄像头预览悬浮窗,可拖动,可显示在其他app上方

    市面上常见的摄像头悬浮窗,如微信.手机QQ的视频通话功能,有如下特点: 整屏页面能切换到一个小的悬浮窗 悬浮窗能运行在其他app上方 悬浮窗能跳回整屏页面,并且悬浮窗消失 我们探讨过用CameraX打 ...

  5. 玩转Android Camera开发(四):预览界面四周暗中间亮,仅仅拍摄矩形区域图片(附完整源代码)

    杂家前文曾写过一篇关于仅仅拍摄特定区域图片的demo.仅仅是比較简陋.在坐标的换算上不是非常严谨,并且没有完毕预览界面四周暗中间亮的效果,深以为憾.今天把这个补齐了. 在上代码之前首先交代下,这里面存 ...

  6. Android摄像头:只拍摄SurfaceView预览界面特定区域内容(矩形框)---完整(原理:底层SurfaceView+上层绘制ImageView)

    Android摄像头:只拍摄SurfaceView预览界面特定区域内容(矩形框)---完整实现(原理:底层SurfaceView+上层绘制ImageView) 分类: Android开发 Androi ...

  7. Android CameraX 打开摄像头预览

    目标很简单,用CameraX打开摄像头预览,实时显示在界面上.看看CameraX有没有Google说的那么好用.先按最简单的来,把预览显示出来. 引入依赖 模块gradle的一些配置,使用的Andro ...

  8. Android 摄像头预览悬浮窗

    用CameraX打开摄像头预览,显示在界面上.结合悬浮窗的功能.实现一个可拖动悬浮窗,实时预览摄像头的例子. 这个例子放进了单独的模块里.使用时注意gradle里的细微差别. 操作摄像头,打开预览.这 ...

  9. Android Camera开发系列(下)——自定义Camera实现拍照查看图片等功能

    Android Camera开发系列(下)--自定义Camera实现拍照查看图片等功能 Android Camera开发系列(上)--Camera的基本调用与实现拍照功能以及获取拍照图片加载大图片 上 ...

随机推荐

  1. 关于操作系统:eos、deepin

    朋友星神推荐了这两个操作系统:eos.deepin,大致看了一下介绍,貌似看起来很棒,界面清新,而且开源,支持的应用也不少,后续我准备尝试一下.此处Mark一下: 官网分别为: https://ele ...

  2. 在CentOS7(虚拟机)下通过源码安装Postgresql10以及基本配置

    操作系统:CentOS7 安装文件:postgresql-10.0.tar.gz 系统环境:gcc.Python 1:源码安装 [postgres@localhost ~]# tar zxvf pos ...

  3. SpringMVC+Spring+mybatis项目从零开始--Spring mybatis mysql配置实现

    上一章我们把SSM项目结构已搭建(SSM框架web项目从零开始--分布式项目结构搭建)完毕,本章将实现Spring,mybatis,mysql等相关配置. 1.    外部架包依赖引入 外部依赖包引入 ...

  4. Webview跨域访问风险

    漏洞原理:WebView对象的行为是通过WebSettings类进行设置的,如果配置不当,攻击者就可以利用该漏洞可以打破Android沙盒隔离机制,从而通过某个应用来攻击其它应用,盗取其它应用本地保存 ...

  5. intellij 创建测试

    之后再test目录下面创建java的文件夹,悲催的发现不能创建.想了好久,之后找到再本机的目录,手动创建java文件夹,然后点击test文件夹 ,并且点击下面的Tests文件夹 设置完test-> ...

  6. SpringMVC学习笔记三:拦截器

    一:拦截器工作原理 类比Struts2的拦截器,通过拦截器可以实现在调用controller的方法前.后进行一些操作. 二:拦截器实现 1:实现拦截器类 实现HandlerInterceptor 接口 ...

  7. 〖Linux〗安装和使用virtualenv,方便多个Python版本中切换

    1. 安装pip easy_install pip 2. 安装virtualenvwrapper sudo pip install virtualenvwrapper 3. 使用virtualenv ...

  8. Selenium简单测试页面加载速度的性能(Page loading performance)

    利用selenium的可以执行javascript脚本的特性,我写了一个java版本的获得页面加载速度的代码,这样你就可以在进行功能测试的同时进行一个简单的测试页面的加载速度的性能测试. 我现在的项目 ...

  9. ArcGIS进行自定义投影转换(重投影)

    这里记录一下使用自定义七参数进行投影转换的过程. 1.主动创建自定义地理(坐标)变换 首先在系统工具箱里面选择创建自定义地理(坐标)变换 在弹出的窗口中输入相关参数即可. 转换方法选择COORDINA ...

  10. 拦截导弹问题(NOIP1999)

    某国为了防御敌国的导弹袭击,开发出一种导弹拦截系统,但是这种拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度, 但是以后每一发炮弹都不能高于前一发的高度.某天,雷达捕捉到敌国的导弹来袭,由于该 ...