Note that there are some explanatory texts on larger screens.

plurals
  1. POThe captured image from camera is not storing in full size
    primarykey
    data
    text
    <p>I know this question has been asked so many times in this forum. But still I couldn't get the solution. Basically in my application, I am calling an inbuilt camera intent, capturing image and displaying a bitmap in imageview and storing it in sd card. Now the image what i get in my folder is of small size like a thumbnail.</p> <p>My code is</p> <pre><code> Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(Intent.createChooser(cameraIntent, "Select picture"), CAMERA_REQUEST); protected void onActivityResult(int requestCode, int resultCode, Intent data) { try { if (requestCode == CAMERA_REQUEST) { Bitmap photo = (Bitmap) data.getExtras().get("data"); if (photo != null) { imageView.setImageBitmap(photo); } // Image name final ContentResolver cr = getContentResolver(); final String[] p1 = new String[] { MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATE_TAKEN }; Cursor c1 = cr.query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC"); if (c1.moveToFirst()) { String uristringpic = "content://media/external/images/media/" + c1.getInt(0); Uri newuri = Uri.parse(uristringpic); String snapName = getRealPathFromURI(newuri); Uri u = Uri.parse(snapName); File f = new File("" + u); String fileName = f.getName(); editTextPhoto.setText(fileName); checkSelectedItem = true; ByteArrayOutputStream bos = new ByteArrayOutputStream(); photo.compress(CompressFormat.PNG, 0 /* ignored for PNG */, bos); byte[] bitmapdata = bos.toByteArray(); // Storing Image in new folder StoreByteImage(mContext, bitmapdata, 100, fileName); sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); // Delete the image from the Gallery getContentResolver().delete(newuri, null, null); } c1.close(); } } catch (NullPointerException e) { System.out.println("Error in creating Image." + e); } catch (Exception e) { System.out.println("Error in creating Image." + e); } System.out.println("*** End of onActivityResult() ***"); } public String getRealPathFromURI(Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(contentUri, proj, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } public boolean StoreByteImage(Context pContext, byte[] pImageData, int pQuality, String pExpName) { String nameFile = pExpName; // File mediaFile = null; File sdImageMainDirectory = new File( Environment.getExternalStorageDirectory() + "/pix/images"); FileOutputStream fileOutputStream = null; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 0; Bitmap myImage = BitmapFactory.decodeByteArray(pImageData, 0, pImageData.length, options); if (!sdImageMainDirectory.exists()) { sdImageMainDirectory.mkdirs(); } sdImageMainDirectory = new File(sdImageMainDirectory, nameFile); sdImageMainDirectory.createNewFile(); fileOutputStream = new FileOutputStream( sdImageMainDirectory.toString()); BufferedOutputStream bos = new BufferedOutputStream( fileOutputStream); myImage.compress(CompressFormat.JPEG, pQuality, bos); bos.flush(); bos.close(); } catch (FileNotFoundException e) { Toast.makeText(pContext, e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } catch (IOException e) { Toast.makeText(pContext, e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } </code></pre> <p>and ImageView in main.xml is </p> <pre><code> &lt;ImageView android:id="@+id/test_image" android:src="@drawable/gray_pic" android:layout_width="180dp" android:layout_height="140dp" android:layout_below="@id/edit2" android:layout_toRightOf="@id/edit3" android:layout_alignParentRight="true" android:layout_marginTop="7dp" android:layout_marginBottom="5dp" android:layout_marginLeft="7dp" android:layout_marginRight="7dp" /&gt; </code></pre> <p>With this code i get an Imageview and the image stores in my folder with small size. If I add intent.putExtra then neither image captured displays in ImageView nor image creates in new folder.</p> <pre><code>Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String path = Environment.getExternalStorageDirectory().getAbsolutePath(); path += "/myFolder/myPicture.jpg"; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); cameraIntent.putExtra("output", outputFileUri); startActivityForResult(Intent.createChooser(cameraIntent, "Select Picture"), CAMERA_REQUEST); } </code></pre> <p>Don't know where I am struck.. Any help on this would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload