0

i am creating an android app where in i am getting all the images from the gallery to display in a grid view in my activity. I am also displaying checkboxes along with the images so the user can select multiple images and upload it to the server. to upload it to the server i am using

UploadToServer.class

and the calling function to this class is

UploadToServer upload=new UploadToServer();
public void uploadImage(View v){

     progressDialog = ProgressDialog.show(MultiPhotoSelectActivity.this, "", "Uploading files to server.....", false);
     Thread thread=new Thread(new Runnable(){
        public void run(){
            for( int i=0;i<selectedItems.size();i++)
            {
                doFileUpload(selectedItems.get(i));
                runOnUiThread(new Runnable(){
                    public void run() {
                        if(progressDialog.isShowing())
                            progressDialog.dismiss();
                    }
                });
           }
        }
});

thread.start();

}
private void doFileUpload(String imagepath) {
    // TODO Auto-generated method stub

    try{
            upload.uploadFile(imagepath);

    }
    catch(Exception e){

        Log.e("log_tag", "Error in http connection "+e.toString());

        }
}

I want to put a compression code for the images as the user is gonna select multiple images...can somebody please suggest what compression code to use and where should i put it??? i m very new to android app development and i hav never used any image compression code before.. Please suggest where can i put a compression code for images in my app???

Please help!

Thanks in advance!

shivani
  • 746
  • 3
  • 22
  • 40

2 Answers2

1

Using Compress method of bitmap:

bm.compress(Bitmap.CompressFormat.JPEG,
                    compressQuality, bos);

where bos is ByteArrayOutputStream object.

Sagar Maiyad
  • 12,655
  • 9
  • 63
  • 99
  • after this if i put it into a byte array then how do i use this byte array to send it over to the server?? – shivani May 30 '13 at 10:12
0

this will helpful to you imgae shrink code

anddevmanu
  • 1,459
  • 14
  • 19