No Solution?????

On Wed, Jul 20, 2011 at 10:15 AM, Ankit Kasliwal <
kasliwalankit2...@gmail.com> wrote:

> Hello Everyone,
>                        I have two problem in my camera Application please
> anyone help me to solve this issue.
>
>  Error :-  *native_jpeg_encode: jpeg_encoder_encode failed.*
> 2. *jpeg encoding failed*
> Please any one help me
> Thanks !!!
>
> *My Code is here:- *
>
> package com.info.police;
>
> import java.text.SimpleDateFormat;
> import java.util.Calendar;
>
> import android.app.Activity;
> import android.content.Context;
> import android.content.Intent;
> import android.graphics.ColorMatrix;
> import android.graphics.
> ColorMatrixColorFilter;
> import android.graphics.Paint;
> import android.graphics.PixelFormat;
> import android.hardware.Camera;
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationManager;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.MotionEvent;
> import android.view.SurfaceHolder;
> import android.view.SurfaceView;
> import android.view.View;
> import android.view.Window;
> import android.view.WindowManager;
> import android.widget.Button;
>
> public class TakePic extends Activity implements LocationListener {
>
>     private static final String TAG = "Camera";
>     Camera camera;
>     private SurfaceHolder previewHolder=null;
>     private Camera mCamera=null;
>     private SurfaceView preview=null;
>     Button buttonClick , btnNew;
>     LocationManager locationManager;
>     double lat , lag;
>     String dateNow,extStorageDirectory,ImgName,Path;
>     public static final int LARGEST_WIDTH = 200;
>     public static final int LARGEST_HEIGHT= 200;
>     String PImgString ;
>
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>
>         super.onCreate(savedInstanceState);
>         // Hide the window title.
>         requestWindowFeature(Window.FEATURE_NO_TITLE);
>         getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
>         setContentView(R.layout.cameralayout);
>         preview=(SurfaceView)findViewById(R.id.preview);
>         previewHolder=preview.getHolder();
>         previewHolder.addCallback(surfaceCallback);
>         previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>         Initialise();
>         btnNew.setEnabled(false);
>         buttonClick.setOnClickListener(new BtnClickListener());
>         btnNew.setOnClickListener(new BtnNewClick());
>         Log.d(TAG, "onCreate'd");
>         setTitle("Tack Image");
>     }
>
>
>     @Override
>     public boolean dispatchTouchEvent(MotionEvent ev) {
>         //-- When we touch the screen, it will auto-focus again
>         if(mCamera != null)
>         {
>             mCamera.autoFocus(new Camera.AutoFocusCallback(){
>             public void onAutoFocus(boolean success, Camera    camera)
>                 {
>
>                 }
>             } );
>         }
>         return super.dispatchTouchEvent(ev);
>     }
>
>     private void Initialise()
>     {
>         buttonClick = (Button) findViewById(R.id.buttonClick);
>         btnNew  = (Button) findViewById(R.id.btnNew);
>         locationManager = (LocationManager)
> getSystemService(Context.LOCATION_SERVICE);
>     }
>
>     class BtnClickListener implements View.OnClickListener{
>
>         public void onClick(View v) {
>             try {
>                 takePicture();
>             } catch (InterruptedException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>             buttonClick.setEnabled(false);
>             btnNew.setEnabled(true);
>         }
>     }
>
>     private void takePicture() throws InterruptedException {
>         mCamera.takePicture(null, null, photoCallback);
>         Thread.sleep(3000);
>
>     }
>
> SurfaceHolder.Callback surfaceCallback=new SurfaceHolder.Callback() {
>
>
>         public void surfaceCreated(SurfaceHolder holder)
>         {
>             mCamera=Camera.open();
>             try
>             {
>                 mCamera.setPreviewDisplay(previewHolder);
>                 mCamera.setOneShotPreviewCallback(null);
>                 ColorMatrix cm = new ColorMatrix();
>                 cm.setSaturation(.5f);
>                 //paint.setColorFilter(new ColorMatrixColorFilter(cm));
>
>             }
>             catch (Throwable t)
>             {
>                 //Log.e("PictureDemo-surfaceCallback","Exception
> insetPreviewDisplay()", t);
>                 //Toast.makeText(TakePic.this,t.getMessage(),
> Toast.LENGTH_LONG).show();
>             }
>         }
>
>         public void surfaceChanged(SurfaceHolder holder,int format, int
> width, int height) {
>             Camera.Parameters parameters=mCamera.getParameters();
>
>
>
>             //parameters.setPreviewSize(100, 100);
>             parameters.setPictureSize(100, 100);//parameters.setZoom(1);
> /*Not in 1.6*/
>             //parameters.setZoom(0); /*Not in 1.6*/
>             parameters.setPictureFormat(PixelFormat.JPEG);
>             //parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
> /*Not in 1.6*/
>             //parameters.setJpegQuality(100); /*Not in 1.6*/
>             mCamera.setParameters(parameters);
>             mCamera.startPreview();
>
>
>
>         //-- Must add the following callback to allow the camera
> toautofocus.
>             mCamera.autoFocus(new Camera.AutoFocusCallback(){
>                 public void onAutoFocus(boolean success, Camera camera)
>                 {
>                 }
>
>             } );
>         }
>
>         public void surfaceDestroyed(SurfaceHolder holder) {
>             if(mCamera != null){
>                 mCamera.stopPreview();
>                 mCamera.release();
>                 mCamera=null;
>             }
>         }
>     };
>
>     Camera.PictureCallback photoCallback=new Camera.PictureCallback() {
>         public void onPictureTaken(byte[] data, Camera camera) {
>
>
>             ImgName = String.format("%d.jpg", System.currentTimeMillis());
>             //FileOutputStream outStream = null;
>             try {
>                 byte[] imgBtye = data;
>                 ColorMatrix cm = new ColorMatrix();
>                 float contrast = 2;
>                 float brightness = 0;
>                 cm.set(new float[] { contrast, 0, 0, 0, brightness,0,
> contrast, 0, 0, brightness,0, 0, contrast, 0, brightness,    0, 0, 0,
> contrast, 0 });
>                 Paint paint = new Paint();
>                 cm.setSaturation(2f);
>                 paint.setColorFilter(new ColorMatrixColorFilter(cm));
>
>                 //Log.d(TAG, "onPictureTaken - wrote bytes: " +
> imgBtye.toString());
>
>                 GetLocationService();
>
>                 Intent i = new Intent(TakePic.this, AddDetail.class);
>                 PImgString = new String(imgBtye);
>                 i.putExtra("ImgString", PImgString);
>                    i.putExtra("Pimg", imgBtye);
>                    i.putExtra("lat", lat);
>                    i.putExtra("lag", lag);
>                    i.putExtra("IName", ImgName);
>                    startActivity(i);
>             }
>             finally
>             {
>
>             }
>         }
>     };
>
>
>     class BtnNewClick implements View.OnClickListener
>     {
>
>         public void onClick(View v) {
>
>             mCamera.startPreview();
>             buttonClick.setEnabled(true);
>             btnNew.setEnabled(false);
>         }
>
>     }
>
>         public void convertDateToString()
>         {
>             Calendar currentDate = Calendar.getInstance();
>             SimpleDateFormat formatter= new SimpleDateFormat("yyyy/MM/dd");
>             dateNow = formatter.format(currentDate.getTime());
>             Log.d("Cueernt Date", "Current System Date" + dateNow);
>         }
>
>
>     private void GetLocationService()
>     {
>         locationManager = (LocationManager)
> getSystemService(Context.LOCATION_SERVICE);
>         Location location =
> locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
>         if( location != null ) {
>
>              lat = location.getLatitude();
>              lag = location.getLongitude();
>              Log.d("Current Location", "Current System Location" + lat + "
> : Lag " + lag);
>         }
>         else
>         {
>             Log.d("Current Location", "No Location Found");
>         }
>     }
>
>
>     public void onLocationChanged(Location arg0) {
>
>
>     }
>
>
>     public void onProviderDisabled(String arg0) {
>
>
>     }
>
>
>     public void onProviderEnabled(String provider) {
>
>
>     }
>
>
>     public void onStatusChanged(String provider, int status, Bundle extras)
> {
>
>
>     }
> }
>
>
>
> --
>
> Thanks and Regards,
>
> Ankit Kasliwal
> kasliwalankit2...@gmail.com
> +91-9300-940-136
>



-- 

Thanks and Regards,

Ankit Kasliwal
kasliwalankit2...@gmail.com
+91-9300-940-136

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to