×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    11

    Image Size Limitations

    Hi there,
    I have been working on a game project recently and it is close to end. I'm using a big Image(in micro terms) 1100*416 PNG image with a transparent background. The way I display is to use setClip() and adjust the locations for drawImage() .
    From the beginnning I was testing with N-Gage and it all went fine. I can say I had 20 frames per second and each time about 30 images to draw from same file plus some other drawings it works really fine and fast!!. couple of days ago I got 6600 and 3650 as well to try.
    6600, was a bit slower when I come to part to show this big file , but then 3650 was unable to load it and then for sure when Itry to display that Image ,it sends nullpointerexception. I read through this forum at least for the last 2 hours and seems like my problem could be a phone memory problem or just the image size is bigger than the limits of phones . Second makes more sense for me because in case of memory problem applicationshould send outofmemory or runtime problem etc.
    If I am right and really exists limits for image sizes how can I learn these limits for different phones.

    Thanks in advance, hope you guys can give me some hints.

    ¤SerdaR¤

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Switzerland
    Posts
    78
    I dont remember the heap sizes but as far as I remember the 3650 gives a lot less.
    Did you try to write what the IOException is when you try to load the image ?
    anyway, it is a VERY large image Will use close to one MB.

    Lucky you that you dont want this running on the phones with limited graphics (SonYEricsson Z600 got around 80 kb for graphics).

    Try with a smaller (just for test) image and see if it runs on 3650, then you can track the problem down.. and do write the Exception error to the screen.

    -Sam

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Yep, the image is just too big.
    If I remember correctly the 3650 has around 1MB of RAM. An image that size will take almost 900KB, so if the rest of the classes (uncompressed) and data are more then 100KB then you're running out of memory.

    shmoove

  4. #4
    Registered User
    Join Date
    Feb 2004
    Posts
    11
    first of all thanks for your comment clearly I'm having the problem which you mentioned. Do you think will it help if I seperate this PNG file to smaller ones. For example I might use ten times 200*208 images instead of this big one. I thought using just one image might be easier and faster but it was just a guess not based on any technical fact.

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Separating the images can help, provided that you don't try to load all of the images at once (in that case you'll be using even more memory). But with the Series 60 memory leak issues when reading resources, you might still get the problems.
    Try to see if there is anyway you can use less images. Maybe using DirectGraphics to draw flipped and rotated images, or even to play around with colors.

    shmoove

  6. #6
    Registered User
    Join Date
    Feb 2004
    Posts
    11
    Unfortunately I can not afford to ignore any of the portion of image. But rotating and converting colors can help significantly. Would you mind pasting here some simple examples for these methods(I want to use them during canvas-graphics)
    And I got one more idea, even though it is time consuming I can draw some of images by using drawLine,drawRect,fillReact,...... methods. For example a portion of 40*40 might be drawn with 30-40 statements, Do you think is this faster than drawing the image from Image variable?

  7. #7
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Switzerland
    Posts
    78
    I dont know how your image looks like, but if possible then you should consider if you can split it up into small tiles (lets say 32x32 pixels.. ) and see if you can reuse tiles. Lets say your game is a platform game or a shootemup then you often can save LOTS of memory.
    Drawing it can in some cases be a lot slower, all depends on how you implement it (also depending on the sizes of the tiles).

    -Sam

  8. #8
    Registered User
    Join Date
    Feb 2004
    Posts
    11
    Hi again,
    last night I tryed to seperate my image to 12 pieces and create a new algorith to display them. Guess what ? I could get them 10 of them but not the last two. Game runs fast and efficiently until it needs those 2 images. Perhaps most simplest way would be just not to use those 2 images but I want to find more stable solutions.
    Now I'm trying to draw them myself with graphic methods(). each small tiles takes about 15-20 statements to draw. And in fact if I can do it, this will be much more efficient because then I will have dynamic color variables. I will be glad if anyone had experience with this kind of trial. Do you have any comments on the performance compared to using images from Image variable.

  9. #9
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Switzerland
    Posts
    78
    Sounds like a lot of statements to draw a single tile ! Specially since you have so few tiles.

    If you create small tiles (32x32) then you need a map, and yeah, drawing a lot of tiles will create an overhead of course compared to drawing a single image. But the trick is to be able to reuse the same graphics again and again. Depending on the device it is possible to flip the tiles vertical and horizontal, which can even improve things a lot. One example is the GameBoy to GameBoyAdvance, there the tile map is define by 8x8 pixel tiles, but the drawing is done by hardware (actually, no drawing but rather just displaying the tiles directly by the LCD hardware).

    On phones 8x8 pixels can slow things down a lot if you try to draw the tiles all the time, there it is often better to have a buffer you draw into, and when you then scroll left/right/up/down you just draw the new tiles into this buffer. But in case of 32x32 (or so) you can draw all the tiles each frame.

    Hope this gives you a few ideas. Then again, depending on your image it might not make sense to use tiles, only if you can reuse graphics...

    -Sam

  10. #10
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    As for examples of flipping, rotating, etc., search these forums for the keyword "DirectGraphics" and you'll get more than a few examples of all of these.

    shmoove

  11. #11
    Registered User
    Join Date
    Feb 2004
    Posts
    11
    Ok finally I got it work as it should even better than how I was expecting before. I menaged to skip more than half of my images without losing any of their display possiblity. In additon I got Color free images which makes my life easier. Thanks guys (sam and shmoove ) for your hints.

Posting Permissions

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