Ich bin sehr neu in Android und möchte eine Bildverarbeitungs-App erstellen. Ich habe einen Code in die Kamera eines Android-Handys aufgenommen und zeigt das aufgenommene Foto auf einer Bildansicht ... Der Code funktioniert gut, das Problem ist, dass ich nicht scheinen kann, um den Grayscaling-Code zu arbeiten. Oder ich kann nicht scheinen, das Graustufenbild auf der Bildansicht zu zeigen ... Bitte brauche ich deine Hilfe. Vielen Dank.Wie skaliert man ein Bild in der Bildansicht?
Erfassung Kamera Code Dies ist das Bild, das
public class CameraActivity extends ActionBarActivity {
static final int REQUEST_IMAGE_CAPTURE = 1;
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
Button button = (Button) findViewById(R.id.button);
//King ina, button2 for processing
Button button2 = (Button) findViewById(R.id.button2);
imageView = (ImageView) findViewById(R.id.imageView);
//Disable the button if it has no camera
if (!hasCamera())
button.setEnabled(false);
}
//Check if the user has camera
private boolean hasCamera() {
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
}
//Launching the camera
public void launchCamera(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//Take a picture and pass result along to onActivityResult
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
//Show image on imageView
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
//Get the photo
Bundle extras = data.getExtras();
Bitmap image = (Bitmap) extras.get("data");
imageView.setImageBitmap(image);
}
}
}
Während dies ist der Code für Grauskalierung des Bildes gut funktioniert ... Kann ich den Aufhebungscode nur wiederholen, die das aufgenommene Bild zeigt? Vielen Dank ...
public Bitmap imageProcess(Bitmap image) {
int width, height;
height = image.getHeight();
width = image.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(image, 0, 0, paint);
return bmpGrayscale;
}
Vielen Dank für die Annahme der Antwort –