×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Post Sending image to another cellphone by using sockets

    Hi everyone!
    I currently send images to another cellphone by using sockets, the problem is that sometimes the client doesnt receive the complete image, so it receives 80% or 90% and that image

    Server side: where I send the image

    f = open(PHOTOPath, 'rb')
    img = f.read()
    f.close()
    conn.send(img)
    conn.close()

    Client side:where i receive the image

    data = conn.recv(4096)
    Alldata = ""

    #a=time.clock()
    try:
    while data!="":
    Alldata += data
    data = conn.recv(4096)
    f = open("e:\\image.jpg", "wb")
    f.write(Alldata)
    f.close()
    except:
    f = open("e:\\image.jpg", "wb")
    f.write(Alldata)
    f.close()

    It works, but sometimes I got a bad image, what is a bad image?, is an image with the bytes incomplete

    Please help me, i will be so graceful!

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Sending image to another cellphone by using sockets

    hi alpinet
    the seems bit correct the problem may due some type of connection problem thats why you are receiving a bad image.
    moreover try this
    hope this will help you

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Sending image to another cellphone by using sockets

    Quote Originally Posted by Alpinet View Post
    Hi everyone!
    I currently send images to another cellphone by using sockets, the problem is that sometimes the client doesnt receive the complete image, so it receives 80% or 90% and that image

    Server side: where I send the image

    f = open(PHOTOPath, 'rb')
    img = f.read()
    f.close()
    conn.send(img)
    conn.close()

    Client side:where i receive the image

    data = conn.recv(4096)
    Alldata = ""

    #a=time.clock()
    try:
    while data!="":
    Alldata += data
    data = conn.recv(4096)
    f = open("e:\\image.jpg", "wb")
    f.write(Alldata)
    f.close()
    except:
    f = open("e:\\image.jpg", "wb")
    f.write(Alldata)
    f.close()

    It works, but sometimes I got a bad image, what is a bad image?, is an image with the bytes incomplete

    Please help me, i will be so graceful!
    Hi Alpinet,

    Could you modifiy this line and try,

    Code:
    while data!=NONE:
    And yes, while posting some code, please use the CODE tabs so that the indents are maintained, which helps others to understand the code better.

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    17

    Re: Sending image to another cellphone by using sockets

    Hi everyone, thanks for your replys you are great!!

    I was wondering how can i make all the process faster, cause it looks very slow the streaming video.

    So, unforntually i have to save the image received into a file to then open it again cause i didnt find any information about how pys60 may transform the bytes to image

    Code:
                      
    f = open("e:\\image.jpg", "wb")
    f.write(dataReceived)
    f.close()
    
    im = graphics.Image.open('e:\\image.jpg')
    canvas.blit(im,target=(19,28),source=((19,28),(259,217)))
    I try so many things I am running out of ideas here

    Thanks for any tip or comment
    Last edited by Alpinet; 2008-05-29 at 20:30. Reason: missing more info

  5. #5
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Helsinki
    Posts
    376

    Re: Sending image to another cellphone by using sockets

    Quote Originally Posted by Alpinet View Post
    Hi everyone, thanks for your replys you are great!!

    I was wondering how can i make all the process faster, cause it looks very slow the streaming video.
    Maybe OpenGL helps. See API doc about GL and accessing raw image pixel data with PyS60:

    glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels)
    Parameter pixels must be either a Python string, a gles.array object, or graphics.Image object.
    Python strings are taken as literal data with no conversion. The dimension and type of data in
    gles.array objects are ignored: the raw data in the array is used.
    Use of graphics.Image objects is limited to only some combinations of format and type. Ta-
    ble 5.6.3 below shows the accepted combinations. To get the best results and performance, the
    CFbsBitmap object in the graphics.Image object should be in the equivalent display mode, also
    shown in the table below. Otherwise, the CFbsBitmap object will be first converted to the equiva-
    lent display mode before reading its pixel data, which can degrade the visual quality in some cases.
    Mikko Ohtamaa

    http://mfabrik.com
    http://blog.mfabrik.com

Similar Threads

  1. How can resize the large size image for sending MMS.
    By Namdeo in forum General Messaging
    Replies: 1
    Last Post: 2007-10-12, 11:34
  2. --- ???save image problem??? ---
    By ferenn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2007-10-01, 14:33
  3. Sending a bitmap image using bluetooth
    By ckt in forum Bluetooth Technology
    Replies: 1
    Last Post: 2006-12-07, 11:10
  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. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58

Posting Permissions

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