1. Check out our companion app, Forums for Android! Download from Google Play

saving Image

Discussion in 'Application Development' started by Haya, Mar 8, 2010.

  1. Haya

    Haya New Member
    Thread Starter
    5

    Mar 8, 2010
    1
    0
    5
    Hi

    need a help urgent !!
    I'm done with saving the image after capturing it
    but I face another problem that the image is very small

    and when i try to capatalize it , it become not clear

    the code:
    myImageButton02​
    .setOnClickListener(new OnClickListener() {

    @Override
    public​
    void onClick(View v)

    {
    // create camera intent

    Intent intent = ​
    new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    //Grant permission to the camera activity to write the photo.

    intent.addFlags(Intent.​
    FLAG_GRANT_WRITE_URI_PERMISSION);
    // start the camera intent and return the image

    startActivityForResult(intent,1);
    }
    });


    ---------------------------------

    @Override​
    protected void onActivityResult(int requestCode, int
    resultCode, Intent data)
    {
    super.onActivityResult(requestCode, resultCode, data);

    // if Activity was canceled, display a Toast message

    if (resultCode == RESULT_CANCELED) {
    Toast toast = Toast.makeText(
    this,"camera cancelled", 10000);
    toast.show();
    return;
    }

    // lets check if we are really dealing with a picture

    if (requestCode == 1 && resultCode == RESULT_OK)
    {
    String timestamp = Long.toString(System.currentTimeMillis());
    // get the picture

    Bitmap mPicture = (Bitmap) data.getExtras().get(​
    "data");
    int width = mPicture.getWidth();
    int height = mPicture.getHeight();
    int newWidth = 500;
    int newHeight = 80;
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    Matrix matrix =
    new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    Bitmap resizedBitmap = Bitmap.createBitmap(mPicture, 0, 0, width,
    height, matrix,
    true);







    // save image to gallery

    MediaStore.Images.Media.insertImage(getContentResolver(), resizedBitmap, timestamp, timestamp);

    }​
    }



    thanks
     

    Advertisement

  2. mayakannan

    mayakannan New Member
    25

    Feb 4, 2012
    3
    0
    25

Share This Page

Loading...