Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:38:26+00:00 2026-06-08T17:38:26+00:00

First I use this code to save the photo to the Android’s SD Card:

  • 0

First I use this code to save the photo to the Android’s SD Card:

PictureCallback jpegCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {

    FileOutputStream outStream = null;

    currentFilename = String.format("%d", System.currentTimeMillis());              
    outStream = new FileOutputStream("/sdcard/" + currentFilename + ".jpg");                    
    outStream.write(data);
    outStream.close();

    }
};

Then I am using this code to upload photos on Android devices:

public void uploadPhoto() {

        try {

            // Create HttpPost
            HttpPost post = new HttpPost("http://www.example.com/upload.php");
            HttpClient client = new DefaultHttpClient();
            client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            MultipartEntity entity = new MultipartEntity( HttpMultipartMode.BROWSER_COMPATIBLE );

            // Add the Picture as "userfile"
            entity.addPart( "userfile", new FileBody( 
                new File( "/sdcard/", currentFilename + ".jpg" ),
                "image/jpeg")
            );


            // Send the data to the server
            post.setEntity( entity );
            client.execute( post );


        } catch (Exception e) {
            // catch
        } finally {
            // finally
        }

}

This works on my LG Optimus V running Android 2.2.2 and Droid X running Android 2.3.4

However – a user who has an HTC Evo running 2.3.4 (Same as my Droid X) is experiencing that all of her uploaded photos are scrambled when they are saved to her phone (and when they get to the server). The image looks like an array of jagged colored lines.

Any ideas about what might be going on here and what could be done to remedy the problem?

Update:

I was able to access this phone and when I pull the jpg files off of the sdcard, it says that the files are 3.5 – 4.0 MB in size, but they cannot be opened and may be corrupted… but the files on the other phones work normally.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:38:28+00:00Added an answer on June 8, 2026 at 5:38 pm

    It looks like problem with picture sizes. Decoding data from array to picture when width and heigh are wrong results with scrambled image.

    Pictures might be taken with supported screen sizes:

    Parameters params = camera.getParameters();
    List<Camera.Size> sizes = params.getSupportedPictureSizes();
    

    try to set one of them, for example the biggest, as picture size:

    List<Size> sizes = params.getSupportedPictureSizes();
    Size theBiggest=null;
    int maxWidth = 0;
    for (Size s : sizes) {
        if (s.width > maxWidth) {
            maxWidth = s.width;
            theBiggest = s;
        }
    }
    
    params.setPictureSize(theBiggest.width, theBiggest.height);
    camera.setParameters(params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off I use this code to make the navigation bar always stay fixed;
I use this code to determine checkbox width and height: var chk = $('input[type=checkbox]:first');
This is my first time that I use WCF and Android. So, sorry for
I have an *.ashx (handler) with this code: public void ProcessRequest (HttpContext context) {
First attempt to use this cool site - after searching for 2 hours: So
use this website a lot but first time posting. My program creates a number
I know one awkward solution for this taks will be : first use ct
I have some problem with this mongoid. It's my first time to use mongoDB,
this is my first time trying to use document classes in AS3 and im
this is the my first question in SO witch I use alot btw :).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.