×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    32

    send image from computer to mobile

    i want to send image from computer to mobile using tcp socket
    i tried the following code but it does not work
    could any one help me

    the code in the computer application (server)

    InputStream input=new FileInputStream("dynamics.jpg");

    byte[] buffer=new byte[1024];
    int readData;
    while((readData=input.read(buffer))!=-1){

    output.write(buffer,0,readData);
    }



    the code in the mobile


    int len = is.available(); //where is openInputStream();
    byte [] imgByte = new byte[len];
    ByteArrayOutputStream bStr = new ByteArrayOutputStream();

    int ch = 0;
    while ( (ch = is.read()) != -1 ) {
    bStr.write(ch);
    }
    is.close();

    imgByte = bStr.toByteArray();
    bStr.close();
    Image imgRes = Image.createImage(imgByte, 0, imgByte.length);

    imageItem.setImage(imgRes);

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: send image from computer to mobile

    Quote Originally Posted by souhir View Post
    but it does not work
    In what way "not work"?

    Graham.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: send image from computer to mobile

    This code should work, but as you are reading the image byte by byte this must be going very slow. Try reading in chunks of at least 1024bytes at a time.

    You wrote that you are using TCP Socket, so connecting to TCP socket from S40 device might be issue with some operators gateway which allow only HTTP over WAP, try with HTTPConnection and check.

    thanks
    Ekta

Similar Threads

  1. About image Thumbnails in mobile
    By abhi4u in forum Mobile Java General
    Replies: 8
    Last Post: 2009-02-25, 12:16
  2. send command to computer
    By mindstien in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-01-19, 09:19
  3. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  4. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  5. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×