×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    1

    Question Simple MIDlet help...

    Hi all, im new, and i need to produce a small MIDlet for a college project and i was hoping that someone could help!

    The application is a simple timetable. On opening there will be a list of 5 days (Monday - Friday), on selecting one of these days a jpg image corresponding to the day will be displayed. The images will be on the phones Memory Card. I have a Nokia 6230.

    I have got Sun One Studio 5 Update with the J2ME features. If someone can help me out and point me the right direction, or recommend a book that would help i'd be most apprechiated!

    Thank You
    Ash!

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Dispalying JPEG images

    hi

    You may try following code for getting your images

    it gets a single image
    try
    {
    int cnt=0;
    byte data[] = new byte[10240];

    //10240 bytes is max. size of your image file
    int i=0;
    Image img;
    InputStream imgStream;
    imgStream = getClass().getResourceAsStream(imgPath);
    cnt=imgStream.read(data,0,10240);
    img = Image.createImage(data,0,cnt);

    }
    catch(Exception ex)
    {
    addDebugMessage("Error Getting Image");
    }

    imgPath is path of image on phone

    You may couple your images for time table in the .jar setup file of your application. You may also dispaly png , gif images instead of jpeg images.

    For displaying this image , make a subclass of Canvas class and in its paint method write following code :

    public void paint(Graphics g)
    {
    int X = g.getClipWidth();
    int Y = g.getClipHeight();
    int iX = img.getWidth();
    int iY = img.getHeight();
    g.setColor(255,255,255);
    g.fillRect(0,0,X,Y);//..clears the screen

    //@ before displaying each new image remember to clear the
    //screen by painting it with white rectangle

    g.drawImage(img,(X-iX)/2,(Y-iY)/2,Graphics.LEFT|Graphics.TOP);
    //@ draws your image in centre of screen irrespective of its dimensions
    }


    hope this information may be helpful to you.


    cheers
    Navjot Singh

  3. #3
    Registered User
    Join Date
    Aug 2006
    Location
    Karachi, Pakistan
    Posts
    33

    Unhappy Re: Simple MIDlet help...

    Hi,

    I know that this post is very late, but I am in the same situation and having problems with loading image of resolution 1600x1200 on 6270 and 7370 but images of 800x600 are loading pretty well and even the images of 820x615 are not loading and giving out of memory error on the function call createImage(inputStream).

    Kind regards

    Muhammad Mutahar Aalm

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Question Re: Simple MIDlet help...

    mmalam1 are you using .png image ?

    or what image format !


    Regards
    NEO

  5. #5
    Registered User
    Join Date
    Aug 2006
    Location
    Karachi, Pakistan
    Posts
    33

    Re: Simple MIDlet help...

    Hi Navjot,

    I am using Jpeg format.

    One more thing I need to ask that if it is not possible simply to load the jpeg of size 1600x1200 then do I need to have separate jpeg decoder class? If yes then where can I find one which is faster and acquire less memory?
    I am using a Jpeg decoder to load 1600x1200 jpeg image but it is too slow an it is taking about 54 seconds to decode one 1600x1200 image.

    Kind regards

    Muhammad Mutahar Alam

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: Simple MIDlet help...

    hi Muhhamad,

    I wonder if something described here:
    http://developer.sonyericsson.com/th...D=77126&#77126
    and mentioned on FN:
    http://discussion.forum.nokia.com/fo...jpeg+thumbnail
    can be implemented - in other words - if jpeg images on Nokia devices have thumb embedded in jpeg metadata,

    regards,
    Peter

Posting Permissions

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