You Are Here:

Community: Developer Discussion Boards

#1 Old Image sizes & which server type? - 2009-03-15, 14:33

Join Date: Mar 2009
Posts: 2
Murzo
Offline
Registered User
Hi guys,

I am currently creating a mobile poker game for a Uni project. I am using the Netbeans IDE with the mobility pack installed. In the next 2 days or so I will be creating the game interface and menus. I was wondering as I am relatively new to J2ME, what size (i.e. pixels and memory) images have to be when displaying them on a mobile device and will the mobile resize the images to fit their screens as they are of different screen size?

I am also looking some advice, as i want the game to be multiplayer, what would be the best way to implement this? Should I use webspace to host the game? Or could I have a normal J2SE socketserver and connect to it using J2ME socket client? Any other suggestions?

Any advice much appreciated!

Thanks
Murzo
Reply With Quote

#2 Old Re: Image sizes & which server type? - 2009-03-15, 17:33

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Quote:
Originally Posted by Murzo View Post
I was wondering as I am relatively new to J2ME, what size (i.e. pixels and memory) images have to be when displaying them on a mobile device and will the mobile resize the images to fit their screens as they are of different screen size?
No, it won't resize them. You need images of the right size to suit the screen size of the device. That means, if you want to support more than one screen size, you will probably need different sizes of artwork.

To cope with this, don't write any code that relies on the size of the screen, or the size of any image. Use Canvas.getWidth() and getHeight(), and the sizeChanged() event, to get the size of the screen. Image.getWidth() and getHeight() should be used to get the size of the artwork. Get this right, and you will be able to use the same code on different devices, just by changing the image resources.

(Likewise, use the various methods of the Font class to check the size of the text, as font sizes will vary between devices. If you need to wrap text to the screen width, write your own code for this. Don't split the lines yourself, as this will mess up when the screen or font size changes.)

Different devices will have different limitations regarding images. Nokia devices don't have significant problems. Things you should know:

* PNGs are supported by all devices.. not every device will support JPGs.

* The memory requirements are between two and four bytes per pixel. So, depending on device, an image 256x256 will need anywhere between 128k and 512k.

* Some devices (non-Nokia) have problems with images that are large in either directions, even if they have enough memory. Avoid images larger than 1024 pixels wide or tall. (If you're targetting older, low-end devices, avoid anything larger than 256 pixels in either direction.)

* There is an overhead per image, both in memory, and in the JAR. A common practice is to combine several images into one (for example, one image containing several frames of an animation).

* Get yourself a copy of PNGOUT. It helps to shrink PNG files, to take less JAR space. (This will reduce only the JAR size, not the amount of heap the image will require.)

* Images are discarded from memory when no variable refers to them. You can stop a variable from refering to an image by: myImage = null;

* (There is a bug on MIDP1 Series 60 devices that stops unreferenced images from being discarded.)

Quote:
Originally Posted by Murzo View Post
I am also looking some advice, as i want the game to be multiplayer, what would be the best way to implement this? Should I use webspace to host the game? Or could I have a normal J2SE socketserver and connect to it using J2ME socket client?
You can use a regular socket connection on most devices. However, support for sockets is optional in the MIDP specification. HTTP connection support is mandatory. HTTP is, of course, less flexible. You sent a request, you get a response; you can't keep the connection open for a longer conversation.

Really, your first thing to decide is: which device (or devices) do you want to support?

Cheers,
Graham.
Reply With Quote

#3 Old Re: Image sizes & which server type? - 2009-03-15, 22:39

Join Date: Mar 2009
Posts: 2
Murzo
Offline
Registered User
Thanks for the reply graham,

the devices I am targeting are the more modern handsets with good memory storage and visual displays, or do you mean the makers of the handsets i.e. Nokia, SE, motorola etc. I was hoping it would be cross platform and work on different makes of phones who meet the requirements.

Quote:
However, support for sockets is optional in the MIDP specification. HTTP connection support is mandatory. HTTP is, of course, less flexible. You sent a request, you get a response; you can't keep the connection open for a longer conversation.
Does this mean that all new/modern phones must support Http Connection? and that they can choose to support socket connections. I have n95 8gb which I am hoping will run the game when I'm finished.

Thanks
Murzo
Reply With Quote

#4 Old Re: Image sizes & which server type? - 2009-03-16, 12:35

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Quote:
Originally Posted by Murzo View Post
the devices I am targeting are the more modern handsets with good memory storage and visual displays, or do you mean the makers of the handsets i.e. Nokia, SE, motorola etc. I was hoping it would be cross platform and work on different makes of phones who meet the requirements.
Devices vary primarily in four ways:

* screen size
* heap size (memory for Java objects)
* JAR size (maximum size of application you can install)
* performance

If you code sensibly, you can cope quite easily with changes in screen size, just by switching to a different set of PNGs (smaller or larger).

On the N95, you have lots of heap, no real JAR size limits, and huge amounts of performance (by mobile standards). The advantage of this is that you won't run into too many performance or memory problems. The disadvantage is: you might not realize what a luxury all that memory and cpu is, and you might write something that runs poorly (or not at all) on less devices.

If you were doing this professionally, I'd recommend you define a minimum spec, find the crappiest device that meets it, and work on that.

Since you're doing this as a university project, so you have a tight deadline, and you want to pass, it is probably best not to worry too much about other devices. If the app works on anything else, that's a bonus. If you have time at the end (you won't), you can experiment with other devices.

Quote:
Originally Posted by Murzo View Post
Does this mean that all new/modern phones must support Http Connection? and that they can choose to support socket connections.
All devices that support Java MIDP, not just the new ones, must support HttpConnection. Even crappy old phones from five years ago.

Socket support is optional, but most new devices (last two-three years) will support sockets. That includes all MIDP-2 Nokias, Sonys and Motorolas.

Cheers,
Graham.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing and sending image to server mahesh_aquarius Mobile Java Networking & Messaging & Security 2 2008-12-05 15:09
uploading image to the server knawaz Mobile Java Networking & Messaging & Security 6 2008-10-11 20:27
image upload server API gerrymackenzie Streaming and Video 1 2006-01-18 16:35
changing mime type on server, where do I start Dexy Mobile Java Networking & Messaging & Security 1 2004-10-11 22:57
Change image in camera server emulator jonawebb Symbian Tools & SDKs 2 2003-09-05 15:57

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia