×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    21

    Need help on loading png graphic over HTTP Connection.

    I am try load a .png graphic from tomcat server to MIDlet. There is problem when the graphic is larger than the screen size and using Fullcanvas. It come out the error HTTP Response Code = 404.

    When i using the normal Form or when the graphic screen size is smaller than the screen, there is no problem on loading it.

    Anyone hv any idea???

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    I am using the below code, its work in Form, which i append the image to it, but not work in FullCanvas. Pls help me!!

    c = (HttpConnection)Connector.open(name);
    int status = c.getResponseCode();
    if (status != 200) {
    throw new IOException("HTTP Response Code = " + status);
    }

    int len = (int)c.getLength();
    String type = c.getType();
    if (!type.equals("image/png")) {
    throw new IOException("Expecting image, received " + type);
    }

    if (len > 0) {
    is = c.openDataInputStream();
    byte[] data = new byte[len];
    is.readFully(data);
    return Image.createImage(data, 0, len);
    } else {
    throw new IOException("Content length is missing");
    }

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    I don't see any problem with the http code, but the error you are describing makes no sense at all. 404 status means the resource wasn't found. That has nothing to do with how you'll display the image once you download it. Are you sure you have the right url in the FullCanvas version?

    shmoove

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    yap, i am sure the url is right. i have using another image with the same name to replace it and it work. is it the dimension of the image too large? It was 541x541...maybe this the problem. Got any way of solve it?

    I just found that the image can be load sometime mostly on the 1st run after compile, but most of the time it wont work.


    regards,

    chi boon

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    I can understand that a big image might cause problems, but they should be memory related. An image of 541x541 pixels would take around 500K when loaded, and that's way over the 200K heap size (I'm assuming a Series 30 or 40 device). It's not a reason for getting a 404 response code. The only thing that should cause that is a wrong url.

    shmoove

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    I have found the way to solve the problem. After i reduce the image detail using some image editing sw, it working. Thanks anyway.

Posting Permissions

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