×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Question image creation fails

    Hi,

    I'm trying to make a image as follows:-

    try
    {
    strom = Image.createImage("stromB.png"); // size 48X48
    map0 = Image.createImage("map0.png"); // size 424X286
    }
    catch (Exception e)
    {
    System.out.println("image creatino faild");
    System.out.println(e.getMessage());
    }

    strom wroks fine but mp0 always throw exception. My guess the size is bigger and may be that's why.
    how can use a larger png image in the midlet?
    Are there any limitation for midlet?
    what is the miximum size I could use for midlet?
    Do it now! Today will be yesterday tomorrow - MadSum

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

    Re: image creation fails

    Does code fail on an actual device, the emulator or both? If an actual device, which device (model)?

    What's the file size of these images? Do both files exist? Are they in the correct location from where you're trying to open them? What, exactly, is the exception you get (it would provide a clue as to whether the reason is a missing file, not enough memory, etc.)?

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: image creation fails

    Quote Originally Posted by madsum View Post
    Hi,

    I'm trying to make a image as follows:-

    try
    {
    strom = Image.createImage("stromB.png"); // size 48X48
    map0 = Image.createImage("map0.png"); // size 424X286
    }
    catch (Exception e)
    {
    System.out.println("image creatino faild");
    System.out.println(e.getMessage());
    }

    strom wroks fine but mp0 always throw exception. My guess the size is bigger and may be that's why.
    how can use a larger png image in the midlet?
    Are there any limitation for midlet?
    what is the miximum size I could use for midlet?
    On actual device, the file names in resource bundle are case sensitive - please check the spelling used in code and filename in resource bundle......

    like see mp0 and map0 above... its 0 or O ??
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: image creation fails

    There is not spelling mistake and img files r in \res. I tried Nokia SDK 1.0 java and java micro edition SDK 3 with netbeans 7.0.1. Tested device 5230 and e71.

    For:-

    catch (Exception e)
    {
    System.out.println(e.getMessage());
    }

    output is null.
    I'm sure it is for large file size 7.0 KB. 345X301.
    Do it now! Today will be yesterday tomorrow - MadSum

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: image creation fails

    Try loading both the images in different try catch to get the understanding of the issue - and identify which image is creating this problem and replace the same with different image of bigger size...
    345x301 is not at all a memory issue.... as you can create a image of full screen size on these SDK and devices (check the MMAPI Camera capture example of WTK)
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: image creation fails

    I tried these option it it didn't work. But I found some other way which is working with some extra problem.

    private Image resizeImage(Image src) {
    int srcWidth = src.getWidth();
    int srcHeight = src.getHeight();
    Image tmp = Image.createImage(srcWidth, srcHeight);
    Graphics g = tmp.getGraphics();
    int ratio = (srcWidth << 16) / srcWidth;
    int pos = ratio/2;

    //Horizontal Resize

    for (int x = 0; x < srcWidth; x++) {
    g.setClip(x, 0, 1, srcHeight);
    g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);
    pos += ratio;
    }

    Image resizedImage = Image.createImage(srcWidth, srcHeight);
    g = resizedImage.getGraphics();
    ratio = (srcHeight << 16) / srcHeight;
    pos = ratio/2;

    //Vertical resize

    for (int y = 0; y < srcHeight; y++) {
    g.setClip(0, y, srcWidth, 1);
    g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);
    pos += ratio;
    }
    return resizedImage;

    }//resize image

    The Image has text to inform some stuff. So I can't resize the image to fit in the smaller screen. My intention to draw the complete image without comprising size or information. I will move it bit by bit upon user key event. I don't find any option how to move canvas by using j2me api. Please throw some light to achieve my task.
    Do it now! Today will be yesterday tomorrow - MadSum

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: image creation fails

    Please refer to wiki article - http://www.developer.nokia.com/Commu...ges_in_Java_ME

    it should help you.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. image creation in j2me
    By pushgod in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2009-03-09, 12:45
  2. folder creation fails on N95
    By jvinjam in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 5
    Last Post: 2009-02-05, 18:31
  3. Image creation from RecordStore
    By askii in forum Mobile Java General
    Replies: 5
    Last Post: 2005-09-10, 13:12
  4. Image Creation
    By vodkaloon in forum Symbian
    Replies: 0
    Last Post: 2005-01-26, 14:44
  5. 6620 HttpConnection creation fails with "Symbian OS Error -18"
    By rmanheim in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-03-18, 17:57

Posting Permissions

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