×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jan 2010
    Location
    Pune Maharashtra India
    Posts
    34

    Can't be able to create an image of 1200X900 in j2me

    Hi

    I have written an application, which takes a picture & upload it on the server.

    I have used the following code

    public void capture()
    {
    try
    {
    snap = mVideoControl.getSnapshot(null);
    Image image = Image.createImage(snap, 0, snap.length);
    System.out.println("Image Height = "+image.getHeight());
    System.out.println("Image Width = "+image.getWidth());
    if(size() > 0 && (get(0) instanceof StringItem))
    delete(0);
    // getOtherInput(snap);
    final Image im = createThumbnail(image);
    image = null;
    System.gc();
    Alert alt = new Alert("Review", "Review captured image", null, AlertType.INFO);
    alt.setCommandListener(new CommandListener() {

    public void commandAction(Command arg0, Displayable arg1)
    {
    Canvas canvas = new Canvas() {

    protected void paint(Graphics g)
    {
    if(im != null)
    g.drawImage(im, 110, 90, 3);
    }

    }
    ;
    canvas.setTitle("Review the captured image");
    canvas.addCommand(mOptionCommand);
    canvas.setCommandListener(CameraForm.this);
    parentMidlet.getDisplay().setCurrent(canvas);
    }


    }
    );
    parentMidlet.getDisplay().setCurrent(alt);
    mPlayer.close();
    mPlayer = null;
    mVideoControl = null;
    }
    catch(Exception e) { }
    }


    but If I mention a size in getSnapShot("encoding=jpeg&width=1200&height=900")

    then it give OutOfMenoryException

    Is there any way to overcome this

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Can't be able to create an image of 1200X900 in j2me

    Hello anuprojekar,

    check these articles on Forum Nokia Wiki for reference:

    Java Memory Management

    Memory Usage Images

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  3. #3
    Registered User
    Join Date
    Jan 2010
    Location
    Pune Maharashtra India
    Posts
    34

    Re: Can't be able to create an image of 1200X900 in j2me

    Hey thanks buddy

    but now what do i do to overcome this.

    should I use the garbage collector in order to free the memory.

    or what will be the another way to do so.

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

    Re: Can't be able to create an image of 1200X900 in j2me

    Which device you are using, how much heap memory is available to your app; when you are trying to capture this big snapshot.

    You need free memory of around 1200x900x3 bytes to capture this big image (heightxwidthx3(RGB)) bytes which looks to be a big number > 3MB.... generally on most of devices like S40 recent also you have only 2MB of heapmemory.

    thanks,
    ~Amitabh

    Reduce the size of you snapshot depending on the avaiable free memory in the heap... check from Runtime.getFreeMemory();

  5. #5
    Registered User
    Join Date
    Jan 2010
    Location
    Pune Maharashtra India
    Posts
    34

    Smile Re: Can't be able to create an image of 1200X900 in j2me

    Hey Thanks Amit for your reply

    Since I am using a Nokia 5130 since It has 2mb of Heap so obviously It will not create an Image of size 3MB

    Now I have used Nokia E51 It easily creates an image of 800X600 & successfully uploads it on the server.

    But whenever I tried to print heap size It shows 512000 how is it possible please help me?

    Thanks

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Can't be able to create an image of 1200X900 in j2me

    Quote Originally Posted by anuprojekar View Post
    Hey Thanks Amit for your reply

    Since I am using a Nokia 5130 since It has 2mb of Heap so obviously It will not create an Image of size 3MB

    Now I have used Nokia E51 It easily creates an image of 800X600 & successfully uploads it on the server.

    But whenever I tried to print heap size It shows 512000 how is it possible please help me?

    Thanks
    Hey, this is in byte.So don't confuse with such a big the number.



    Thanks & Regards,
    Ajit

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

    Re: Can't be able to create an image of 1200X900 in j2me

    Nokia E51, please refer to http://www.forum.nokia.com/devices/E51/ has dynamic(unlimited) heap memory size.
    When you try to print available memory it may return correct value, but what you should try is put a try/catch and try to allocate the required byte array for reading image in the memory if throws an exception you understand that heap is low else you contiune your work.

    thanks,
    ~Amitabh

  8. #8
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Can't be able to create an image of 1200X900 in j2me

    it's difficult on such a S60 to retrieve the exact amount of free memory, like mentioned this particular deviced has a dynamic heap size : so the app might get 2MB allocated at the beginning (as an example!) but when these 2 megabytes will nearly be used up the OS will dynamically increase the heap size... So depending on the moment that you are actually quering the amount of free memory the result change a lot during a time frame...

  9. #9
    Registered User
    Join Date
    Jan 2010
    Location
    Pune Maharashtra India
    Posts
    34

    Smile Re: Can't be able to create an image of 1200X900 in j2me

    Thank you very much for helping me

    Now I got the problem.

    Thanks Once Again.

Similar Threads

  1. Create Image2D from filmstrip image
    By YetAnotherUserName in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2009-08-12, 09:14
  2. J2me polish background image problem
    By poojs in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 1
    Last Post: 2009-05-25, 07:08
  3. can we create audio+video file like(3gp) in j2me?
    By premlathiya in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2006-11-24, 10:05
  4. 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
  •  
×