×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Question Mutable Image maximum size?

    Is there a maximum size that a mutable image can have?

    I am creating a mutable image in which i draw the contents of a text file. The width of the image is equal with the screen's width while the height of the image depends on the amount of text that is read from the file. A lot of text, results in a large image height (=m_lastLineY).

    I am testing the application on a Blackberry simulator. When the text that is read from the file is small, the image is created and displayed correctly. However, when the file contains a lot of text (imgHeight = 6900), an exception is thrown in

    PHP Code:
    graphics im.getGraphics(); 
    Is this because of the image height? The same thing works fine on a lot of sony ericsson and nokia emulators.

    PHP Code:
    m_screenWidth midlet.getWidth();

    m_lastLineY getLastLineCoordinate(m_textm_leftMarginm_topMarginm_screenWidth);

    // Create mutable image
    im Image.createImage(m_screenWidthm_lastLineY);

    int imgWidth im.getWidth();
    int imgHeight im.getHeight();

    Graphics graphics null;

    // Get graphics object to draw onto the image
    try {
       
    graphics im.getGraphics();
    } catch (
    Exception e) {



  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Mutable Image maximum size?

    The first limit you will have is memory - see the wiki page on memory usage of images.

    Also, many devices have limits on image size. If you want maximum portability of your code, I recommend using images a maximum of 256 pixels in either direction for devices with screen sizes less than 176 pixels wide, and a maximum of 1024 pixels in either direction for devices with screens 176 pixels and wider.

    What exception is thrown?

    Graham.

  3. #3
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by grahamhughes View Post
    The first limit you will have is memory - see the wiki page on memory usage of images.

    Also, many devices have limits on image size. If you want maximum portability of your code, I recommend using images a maximum of 256 pixels in either direction for devices with screen sizes less than 176 pixels wide, and a maximum of 1024 pixels in either direction for devices with screens 176 pixels and wider.

    What exception is thrown?

    Graham.
    It throws an IllegalArgumentException on the Blackberry simulator and a java.lang.OutOfMemoryError on the Nokia simulator. So I guess it's because of the size of the mutable image that I'm creating. I should use a smaller image then.

    Thanks for your reply.

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Quote Originally Posted by polys View Post
    1. It throws an IllegalArgumentException on the Blackberry simulator and

    2. a java.lang.OutOfMemoryError on the Nokia simulator. So I guess it's because of the size of the mutable image that I'm creating. I should use a smaller image then.

    Thanks for your reply.
    1. Not sure about the Blackberry,whther it was due to the heap/image size

    2.For sure,due to the heap/image size
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by raj_J2ME View Post
    1. Not sure about the Blackberry,whther it was due to the heap/image size

    2.For sure,due to the heap/image size
    Should be a bit tricky to keep creating smaller images rather than a single big image but I have no other choice.

    Thanks for the reply

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Quote Originally Posted by polys View Post
    Should be a bit tricky to keep creating smaller images rather than a single big image but I have no other choice.

    Thanks for the reply
    Why you dont have the other choice, you can go for the smaller images.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by raj_J2ME View Post
    Why you dont have the other choice, you can go for the smaller images.
    Well what my application does is create a mutable image on which it draws text read from a file. I want to scroll that text on the screen, so I create an lwuit mutable image (to use different bitmap fonts) and clip that image on each iteration to give a scrolling effect. I don't know how I will be able to read a small portion of the text at a time, create a smaller image with that text and display it, followed by the next image with the text that follows

  8. #8
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Why don't you just draw the image and then draw the text over this.
    Then you can the width of the viewable area on which you want to draw the string.Now in order to scroll the text you can increase or decrease the Y position of the string on the up or down key events.

    Just move the text over up and down.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  9. #9
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by raj_J2ME View Post
    Why don't you just draw the image and then draw the text over this.
    Then you can the width of the viewable area on which you want to draw the string.Now in order to scroll the text you can increase or decrease the Y position of the string on the up or down key events.

    Just move the text over up and down.
    Thanks Raj.

    I didn't think of doing that.

    I will give it a go and I will let you know how it went.

  10. #10
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Raj I did what you suggested and it works.

    In my application, when the down key is pressed, the text should start scrolling. For this reason I'm using a timer and the image is repainted every time. To be more precise, and as you suggested, the text is painted on the mutable image at a different y coordinate, thus giving the effect of the scrolling text.

    The problem is (and it is a big problem for the application that I am trying to create) the "scrolling" is not smooth at all. I need to make a prompting application and the scrolling appears to be too jerky. When I was painting the entire text on a single mutable image and then just clipping the image, the scrolling effect was much smoother.

    Any ideas?

    What I do is
    PHP Code:
    im com.sun.lwuit.Image.createImage(m_screenWidthm_screenHeight); 
    at the beginning and then, at each interval of the timer

    PHP Code:
    // Draw a filled (black) rectangle
    g.setColor(m_canvas.m_backgroundColor);
    g.fillRect(00im.getWidth(), im.getHeight());

    // Specify the current Font
    g.setFont(m_currentFont);

    // Draw text in white
    g.setColor(m_canvas.m_fontColor);

    int fontHeight m_currentFont.getHeight();
    String s;

    while(
    hasMoreLines())
    {
        
    nextLine().trim();
        
    g.drawString(sxy);
        
    += fontHeight;

    y is the position where the string is drawn. If I want to scroll down, y is negative.

    hasMoreLines() and nextLine() are functions that I found online and are used to wrap the text.

  11. #11
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Well,please note that you are painting the screen continuously on the basis of time.
    Why don't you repaint the screen as soon as you press the key,rather than the this.

    One more thing how many lines are there in total?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  12. #12
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by raj_J2ME View Post
    Well,please note that you are painting the screen continuously on the basis of time.
    Why don't you repaint the screen as soon as you press the key,rather than the this.

    One more thing how many lines are there in total?
    The purpose of the application is to press the down key once and the text will start scrolling. The user doesn't have to press the down key every time to scroll more. This is why I need to paint the screen continuously after each time interval.

    The text that is displayed is read from a text file and can be of any size.

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Quote Originally Posted by polys View Post
    The purpose of the application is to press the down key once and the text will start scrolling. The user doesn't have to press the down key every time to scroll more. This is why I need to paint the screen continuously after each time interval.

    The text that is displayed is read from a text file and can be of any size.
    Okay,that's great.
    Well you can draw the string using the vector in order make the rendering faster.Add the text in the vector and then draw. This can do a faster rendering.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  14. #14
    Regular Contributor
    Join Date
    Jun 2009
    Location
    London
    Posts
    50

    Re: Mutable Image maximum size?

    Quote Originally Posted by raj_J2ME View Post
    Okay,that's great.
    Well you can draw the string using the vector in order make the rendering faster.Add the text in the vector and then draw. This can do a faster rendering.
    What do you mean by "add the text in the vector"? How do I do that?

    Note that in my application I paint the text one line at a time:

    PHP Code:
    while(hasMoreLines()) 

        
    nextLine().trim(); 
        
    g.drawString(sxy); 
        
    += fontHeight

    So if I convert the entire text to a vector, I will still need to wrap the text using the vector.

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Mutable Image maximum size?

    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. how to keep image size same
    By manmay.gupta in forum Symbian User Interface
    Replies: 5
    Last Post: 2009-10-07, 08:13
  2. set Image size
    By blastblast in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-03-12, 10:50
  3. what is the maximum size we can post or retrieve through midp2.0 like nokia 6235
    By Basu in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2006-12-26, 12:24
  4. Maximum size we can post through 6235
    By Basu in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2006-12-19, 07:40
  5. 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
  •  
×