携帯電話のカメラから撮影した完全な品質の画像をアプリにアップロードさせようとしています。唯一の問題は、結果の画像が非常に小さなビットマップであることを除いて、アップロード全体が機能しています。代わりに、完全な品質の画像を取得したいと思います。誰でも私を助けることができますか?これが私のコードです。
public class UploadActivity extends Activity {
public final static int CAMERA_REQUEST = 1888;
InputStream is;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload);
Button takePicture = (Button) findViewById(R.id.take_picture_button);
takePicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, CAMERA_REQUEST);
}
});
Button uploadButton = (Button) findViewById(R.id.send_button);
uploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ImageView mImageView = (ImageView) findViewById(R.id.ivUserImage);
Bundle extras = data.getExtras();
Bitmap mImageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(mImageBitmap);
new fileUpload().execute(mImageBitmap);
}
public class fileUpload extends AsyncTask<Object, Void, Void> {
@Override
protected Void doInBackground(Object... param) {
Bitmap bitmapOrg = (Bitmap) param[0];
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);
byte[] ba = bao.toByteArray();
String ba1=Base64.encodeBytes(ba);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("image",ba1));
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.info/appserver/upload.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
return null;
}
}
}