CopyPastor

Detecting plagiarism made easy.

Score: 1.831388771533966; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2013-03-05
by Aashish Bhatnagar

Original Post

Original - Posted on 2013-03-05
by Aashish Bhatnagar



            
Present in both answers; Present only in the new answer; Present only in the old answer;

use this function to click the image


public void takePhoto1() { if (!android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED)) { Toast.makeText(Add_View_Images_Activity.this, "Please insert SDcard for capturing photo.", Toast.LENGTH_SHORT).show(); } else { try { photo1=new File(fWrapper.path+"/"+System.currentTimeMillis()+".jpg"); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo1)); cameraIntent.putExtra("return-data", true); startActivityForResult(cameraIntent, 4); } catch (Exception e) { Toast.makeText(Add_View_Images_Activity.this, ""+e, Toast.LENGTH_LONG).show(); } } }

this function saves the image at specified location. now you can get the path of the clicked image from the path of the file photo1 in the onActivityResult.
like this

String path=photo1.getAbsolutePath();
now just pass the path that you are getting to this function it works 100% all the time.




















public Bitmap getImage(String path) throws IOException { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); int srcWidth = options.outWidth; int srcHeight = options.outHeight; int[] newWH = new int[2]; newWH[0] = srcWidth/2; newWH[1] = (newWH[0]*srcHeight)/srcWidth; int inSampleSize = 1; while(srcWidth / 2 >= newWH[0]){ srcWidth /= 2; srcHeight /= 2; inSampleSize *= 2; } // float desiredScale = (float) newWH[0] / srcWidth; // Decode with inSampleSize options.inJustDecodeBounds = false; options.inDither = false; options.inSampleSize = inSampleSize; options.inScaled = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(path,options); ExifInterface exif = new ExifInterface(path); String s=exif.getAttribute(ExifInterface.TAG_ORIENTATION); System.out.println("Orientation>>>>>>>>>>>>>>>>>>>>"+s); Matrix matrix = new Matrix(); float rotation = rotationForImage(Add_View_Images_Activity.this, Uri.fromFile(new File(path))); if (rotation != 0f) { matrix.preRotate(rotation); } int newh = ( w * sampledSrcBitmap.getHeight() ) /sampledSrcBitmap.getWidth(); Bitmap r=Bitmap.createScaledBitmap(sampledSrcBitmap, w, newh, true); Bitmap resizedBitmap = Bitmap.createBitmap( r, 0, 0, w, newh, matrix, true); return resizedBitmap; }






The way you are accessing the camera Image you will always get the thumbnail of the image you must be starting the camera using intent, if possible use this function to click the image


public void takePhoto1() { if (!android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED)) { Toast.makeText(Add_View_Images_Activity.this, "Please insert SDcard for capturing photo.", Toast.LENGTH_SHORT).show(); } else { try { photo1=new File(fWrapper.path+"/"+System.currentTimeMillis()+".jpg"); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo1)); cameraIntent.putExtra("return-data", true); startActivityForResult(cameraIntent, 4); } catch (Exception e) { Toast.makeText(Add_View_Images_Activity.this, ""+e, Toast.LENGTH_LONG).show(); } } }

this function saves the image at specified location. now you can get the path of the clicked image from the path of the file photo1 in the onActivityResult.
like this

String path=photo1.getAbsolutePath();
now just pass the path that you are getting to this function it works 100% all the time.




















public Bitmap getImage(String path) throws IOException { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); int srcWidth = options.outWidth; int srcHeight = options.outHeight; int[] newWH = new int[2]; newWH[0] = srcWidth/2; newWH[1] = (newWH[0]*srcHeight)/srcWidth; int inSampleSize = 1; while(srcWidth / 2 >= newWH[0]){ srcWidth /= 2; srcHeight /= 2; inSampleSize *= 2; } // float desiredScale = (float) newWH[0] / srcWidth; // Decode with inSampleSize options.inJustDecodeBounds = false; options.inDither = false; options.inSampleSize = inSampleSize; options.inScaled = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(path,options); ExifInterface exif = new ExifInterface(path); String s=exif.getAttribute(ExifInterface.TAG_ORIENTATION); System.out.println("Orientation>>>>>>>>>>>>>>>>>>>>"+s); Matrix matrix = new Matrix(); float rotation = rotationForImage(Add_View_Images_Activity.this, Uri.fromFile(new File(path))); if (rotation != 0f) { matrix.preRotate(rotation); } int newh = ( w * sampledSrcBitmap.getHeight() ) /sampledSrcBitmap.getWidth(); Bitmap r=Bitmap.createScaledBitmap(sampledSrcBitmap, w, newh, true); Bitmap resizedBitmap = Bitmap.createBitmap( r, 0, 0, w, newh, matrix, true); return resizedBitmap; }







        
Present in both answers; Present only in the new answer; Present only in the old answer;