0

Bitte helfen, ich möchte eine Bildbeschneidung Aktivität vor der Einstellung auf Bild zu zeichnen. Ich möchte beschnittene Bild zu Imageview setzen, ist selb das gleiche .. Hier ist mein CodeAndroid Crop Activity vor dem Einstellen des Bildes zu imageView

public void picselect(View view) { 

    Toast.makeText(this, "Select a Picture", Toast.LENGTH_SHORT).show(); 
     //pic select intent 
    Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
    startActivityForResult(i, RESULT_LOAD_IMAGE); 
} 

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

    if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { 
     Uri selectedImage = data.getData(); 
     String[] filePathColumn = {MediaStore.Images.Media.DATA}; 

     Cursor cursor = getContentResolver().query(selectedImage, 
       filePathColumn, null, null, null); 
     cursor.moveToFirst(); 

     int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 
     String picturePath = cursor.getString(columnIndex); 
     cursor.close(); 
     /*** 
     * i wish launch a crop activity then set cropped image to the imageView 
     ***/ 
     //setting image to imageView 
     imageView = (ImageView) findViewById(R.id.imageView); 
     imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 
     //setting image to selb 
     ImageView selb = (ImageView) findViewById(R.id.contimg); 
     selb.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 
    } 
} 

bitte schnell helfen. Vielen Dank.

+0

Mögliche Duplikat http://stackoverflow.com/questions/15228812/crop-image-in-android –

Antwort

0

Siehe this oder this für Ernte Bild und auf Imageview

+0

Es scheint hilfreich zu sein. Werde versuchen. – EthenolWolf

+0

Können Sie mir bitte sagen, wie man 1: 1 beschneidet. – EthenolWolf

+0

versuchen Sie diese 'intent.putExtra (" aspectX ", 1); intention.putExtra ("aspectY", 1); 'in deiner' Absicht' –

0

Versuchen Sie es!

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

if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { 
    Uri selectedImage = data.getData(); 
    ImageView selb = (ImageView) findViewById(R.id.contimg); 
    selb.setImageUri(selectedImage); 
} 

}

+0

Vielleicht ist dies nicht zum Zuschneiden. – EthenolWolf

+0

Aber danke für den Versuch zu helfen. Ich werde es versuchen. – EthenolWolf

0

Hier ist die Lösung. Danke Jungs für die Unterstützung. Es ist jetzt perfekt.

public void picselect(View view) { 

    Toast.makeText(this, "Select a pic", Toast.LENGTH_SHORT).show(); 
    Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
    startActivityForResult(i, RESULT_LOAD_IMAGE); 
} 

@Override 
protected void onActivityResult(int reqC, int resC, Intent data) { 
    if (resC == RESULT_OK) { 
     if (reqC == RESULT_LOAD_IMAGE) { 
      picUri = data.getData(); 
      performCrop(); 
     } else if (reqC == PIC_CROP) { 
      Bundle extras = data.getExtras(); 
      Bitmap thePic = extras.getParcelable("data"); 
      ImageView picv = (ImageView) findViewById(R.id.imageView); 
      picv.setImageBitmap(thePic); 
      imageView = (ImageView) findViewById(R.id.contimg); 
      imageView.setImageBitmap(thePic); 

     } 
    } 
} 

private void performCrop() { 
    try { 
     Intent cropIntent = new Intent("com.android.camera.action.CROP"); 
     cropIntent.setDataAndType(picUri, "image/*"); 

     cropIntent.putExtra("crop", "true"); 
     // indicate aspect of desired crop 
     cropIntent.putExtra("aspectX", 1); 
     cropIntent.putExtra("aspectY", 1); 
     // indicate output X and Y 
     cropIntent.putExtra("outputX", 200); 
     cropIntent.putExtra("outputY", 200); 
     // retrieve data on return 
     cropIntent.putExtra("return-data", true); 
     // start the activity - we handle returning in onActivityResult 
     startActivityForResult(cropIntent, PIC_CROP); 
    } catch (ActivityNotFoundException anfe) { 
     Toast t = Toast.makeText(this, "ANFE", Toast.LENGTH_SHORT); 
     t.show(); 
    } 
} 
Verwandte Themen