¾ÛÅøÁî
46.¢½.168.138
46.¢½.168.129
46.¢½.168.161
46.¢½.168.136
46.¢½.168.145
46.¢½.168.162
46.¢½.168.144
46.¢½.168.140
115.¢½.135.198
46.¢½.168.139
 
°Ô½Ã¹° 12°Ç
   
- Camera)Ä«¸Þ¶ó ¿ÀǸ¸ ÇÏ´Â ¼Ò½º
±Û¾´ÀÌ : ±è±â¹ü                   ³¯Â¥ : 2010-11-03 (¼ö) 13:40 Á¶È¸ : 3919
Zooms.zip (41.5K), Down : 2, 2010-11-03 13:40:28

÷ºÎ ÀÚ·á´Â °Ö·°½ÃS¿¡¼­ Å×½ºÆ®ÇÑ ¼Ò½ºÀÔ´Ï´Ù.
»çÁøÂï´Â ±â´É°°Àº°Ç ¾ø½À´Ï´Ù. ¼øÀüÀÌ Ä«¸Þ¶ó ¿ÀDZâ´É¸¸ ÇÕ´Ï´Ù.
ÀÎÅͳݿ¡ µµ´Â ¼Ò½º¸¦ »ç¿ëÇÏ´Ï Á¦´ë·Î µ¿ÀÛÀÌ ¾ÈµÅ¾î ÀÌ·±Àú·± ¼Ò½º¸¦ Âü°íÇؼ­
º¯°æ ÀÛ¾÷ÇÑ °ÍÀÔ´Ï´Ù. µ¿ÀÛ µÊ!! ^^;
ÁÖ¼® 󸮸¦ ÇÏÁö ¾ÊÀº ÀÌÀ¯´Â... ±âº»ÀûÀÎ ³»¿ëÀº ±×³É °¡Á®´Ù ¾²¸é µÈ´Ù¶ó°í »ý°¢Çؼ­ÀÔ´Ï´Ù.
¾ÆÁ÷Àº ´Ùµé Àú·¸°Ô ¾²´Ï±ñ... << À̶õ ÀÌÀ¯¹Û¿¡ ¾ÈµË´Ï´Ù ^^; Áö½Ä ºÎÁ·...
°Ë»öÀº Camera.open() << ÀÌ ´Ü¾î·Î °Ë»öÇÏ¸é ¸î°¡Áö ÀÚ·á°¡ ³ª¿É´Ï´Ù.

package com.Zooms;

import android.app.Activity;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import java.io.IOException;
import java.util.List;

// ----------------------------------------------------------------------
//     <uses-permission android:name="android.permission.CAMERA"/> ÆÛ¹Ì¼Ç Ãß°¡
public class main extends Activity {   
    private Preview mPreview;
   
    @Override
 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        // Hide the window title.
        requestWindowFeature(Window.FEATURE_NO_TITLE);
   
        // Create our Preview view and set it as the content of our activity.
        mPreview = new Preview(this);
        setContentView(mPreview);
    }

    /*
     * ¾Æ·¡ ó·³ Ãß°¡ÇÏ¸é »çÁøÂï±â°¡ °¡´ÉÇϴٴ±º¿ä ^^;
     * Á¦°¡ ¸¸µç ¼Ò½º´Â ¼øÀüÈ÷ Ä«¸Þ¶ó¸¦ ¿ÀÇÂÇÏ´Â ±â´ÉÀÔ´Ï´Ù.
     * ³ª¸ÓÁö ±â´ÉÀº °³ÀÎÀÌ °øºÎÇغ¸½Ã°í Àúµµ ¸¸µé¾îº¸´Âµ¥·Î ¿Ã¸®°Ú½À´Ï´Ù.
     * private Preview preview;
     *
     * preview = new Preview(this);
     *
     * buttonClick.setOnClickListener(new OnClickListener(){
     *   public void onClick(View v){
     *    preview.getCamera().takePicture(shutterCallback, rawCallback, jpegCallback);
     *   }
     * });
     * 
     */
}

// ----------------------------------------------------------------------

class Preview extends SurfaceView implements SurfaceHolder.Callback {
    SurfaceHolder mHolder;
    Camera mCamera;
   
    Preview(Context context) {
        super(context);
        mHolder = getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    public Camera getCamera(){
  return mCamera;
    }
   
    public void surfaceCreated(SurfaceHolder holder) {
                mCamera = Camera.open();
        try {
         mCamera.setPreviewDisplay(holder);
//         mCamera.setPreviewCallback(new PreviewCallback());
        } catch (IOException exception) {
            mCamera.release();
            mCamera = null;
            // TODO: add more exception handling logic here
        }
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when we return, so stop the preview.
        // Because the CameraDevice object is not a shared resource, it's very
        // important to release it when the activity is paused.
        mCamera.stopPreview();
        mCamera.release();
        mCamera = null;
    }

    private Size getOptimalPreviewSize(List<Size> sizes, int w, int h){
     final double ASPECT_TOLERANCE = 0.05;
     double targetRatio = (double)w/h;
     
     if (sizes == null){
      return null;
     }
     Size optimalSize = null;
     double minDiff = Double.MAX_VALUE;
     
     int targetHeight = h;
     
     for (Size size : sizes){
      double ratio = (double)size.width/size.height;
      if(Math.abs(ratio-targetRatio) > ASPECT_TOLERANCE){
       continue;
      }
      if(Math.abs(size.height - targetHeight) < minDiff){
       optimalSize = size;
       minDiff = Math.abs(size.height - targetHeight);
      }
     }
     
     if (optimalSize == null){
      minDiff = Double.MAX_VALUE;
      
         for (Size size : sizes){
          double ratio = (double)size.width/size.height;

          if(Math.abs(size.height - targetHeight) < minDiff){
           optimalSize = size;
           minDiff = Math.abs(size.height - targetHeight);
          }
         }
     }
     return optimalSize;
    }
   
    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        // Now that the size is known, set up the camera parameters and begin
        // the preview.
        Camera.Parameters parameters = mCamera.getParameters();
        List<Size> sizes = parameters.getSupportedPreviewSizes();
        Size optimalSize = getOptimalPreviewSize(sizes, w, h);
        parameters.setPreviewSize(optimalSize.width, optimalSize.height);
        mCamera.setParameters(parameters);
        mCamera.startPreview();
    }

}

±¦ÂúÀº Âü°í ºí·Î±× ÀÔ´Ï´Ù
http://blog.naver.com/agapeuni?Redirect=Log&logNo=60104914002






 
°­µ¿¿± 2012-07-01 (ÀÏ) 13:36
¾È³çÇϼ¼¿ä... À§ ¼Ò½º¿Í °°Àº ÇüÅÂÀÇ ÀÚ·áµéÀ» ã¾Æ¼­ È­¸é¿¡ »çÁø ¶Ù¿ö¼­ Âï°í ÀúÀåÇϱ⠱îÁö´Â ÇØ º¸¾Ò´Âµ¥¿ä... °í¹Î¿¡ ºüÁø ºÎºÐÀº takepicuter À» button click ¾È¿¡ ³ÖÀ¸¸é Àß µÇ´Âµ¥... Àú À§¿¡  onContentView ¹Ø¿¡ ¹Ù·Î ³Ö¾î ¹ö¸®¸é ¿À·ù°¡ ³ª¿É´Ï´Ù.  ¿Ö ±×·²±î¿ä ???  ¹öÆ° Ŭ¸¯ ¾øÀÌ »çÁøÀ» Âï¾î º¸°í ½ÍÀºµ¥¿ä...
   

°Ô½Ã¹° 12°Ç
¹øÈ£ Á¦¸ñ ±Û¾´ÀÌ ³¯Â¥ Á¶È¸
12  1ÀÎ ¾Ûâ¾÷ ½ºÅ¸Æ®¾÷ ¼ÒÈ£±â¾÷ ÇÊ»ì±â¸¦ º¸¿©ÁÖ¸¶ ¹Î¼¼¿¬ 12-25 3595
11  ¾Èµå·ÎÀ̵å 4 3 Á©¸®ºó On °¶·°½Ã ³Ø¼­½º ±â´É ¹× Èı⠹ÚÃÊ·Õ 12-25 3549
10  ¾Èµå·ÎÀÌµå °³¹ß °­Á ´ÙÀ̾ó·Î±× 4 Custom Dialog ¹èµåº¸ 12-25 3901
9  ¡¡¡¡¡¡ ¼­»óÀº 12-24 2625
8  ¾×Á¤¿¡ ¼Õ°¡¶ôÀ» ´©¸£´Â ½Ã°£¿¡ µû¸¥ ÇÔ¼ö È£Ãâ +5 ±è±â¹ü 11-15 3270
7  - Camera)Ä«¸Þ¶ó ¿ÀǸ¸ ÇÏ´Â ¼Ò½º +1 ±è±â¹ü 11-03 3920
6  [¸µÅ©]ÇÁ·Î±×·¹½º ´ÙÀ̾ó·Î±×(ProgressDialog)»ý¼ºÇϱâ Å«°õ 10-27 3054
5  [¸µÅ©]¾Èµå·ÎÀ̵å(android) ´ÙÀ̾ó·Î±× Á¾·ùº° ±¸Çö ¹æ¹ý Å«°õ 10-27 3629
4  À§Ä¡Á¤º¸ GPS °£´Ü ¼Ò½º +5 Å«°õ 10-26 3929
3  ¾Ë¾ÆµÎ¸é À¯¿ëÇÑ permission +2 Å«°õ 10-26 3062
2  ¾Ë¾ÆµÎ¸é ÁÁÀº ±â´É ÄÚµå ¸ðÀ½ +3 Å«°õ 10-26 3281
1  Activity À̵¿½Ã ƯÁ¤°ª ³Ñ°ÜÁÖ±â +4 Å«°õ 10-15 3221
 
 
 
Copyright ¨Ï wwwold.androidstudy.co.kr. All rights reserved.