Can I use bar file to load image on Nokia 6585? | developer.brewmp.com Can I use bar file to load image on Nokia 6585? | developer.brewmp.com

Developer

Can I use bar file to load image on Nokia 6585?

Forums:

Hello,

I have a problem with loading bmp image on Nokia 6585. The way I do is storing the images in a bar file and use ISHELL_LoadResImage() to load the image. But this causes power cycle. If I use ISHELL_LoadImage() to load the bmp file directly, the image is displayed correctly. Does anyone know why? And how to solve this problem so that I can use a bar file?

Thanks!

The problem is not the BAR file or the image in the BAR file. You are looking at a program error elsewhere. Just off the cuff I would suspect an alignment error if your app is working properly in the emulator but fails on the handset liek that.

The problem is not the BAR file or the image in the BAR file. You are looking at a program error elsewhere. Just off the cuff I would suspect an alignment error if your app is working properly in the emulator but fails on the handset liek that.

Could you please be more specific? If it is an alignment problem, how can I find where the problem is and solve it? Thanks!

Could you please be more specific? If it is an alignment problem, how can I find where the problem is and solve it? Thanks!

An alignment error occurs when you try to access, say a 32-bit integer that is not aligned on an even memory address. In order to find this sort of problem you may have to debug you application in detail and scan over your data structures to see if their members are evenly aligned.
You can also use the Linker's MAP file to check for the memory addresses of your data structures to begin with and see if the base addresses are all aligned on even addresses.

An alignment error occurs when you try to access, say a 32-bit integer that is not aligned on an even memory address. In order to find this sort of problem you may have to debug you application in detail and scan over your data structures to see if their members are evenly aligned.
You can also use the Linker's MAP file to check for the memory addresses of your data structures to begin with and see if the base addresses are all aligned on even addresses.

Thanks! But I think my problem is a little different. Whether I use ISHELL_LoadResImage() to load an image from the bar file or use ISHELL_LoadResDataEx() to load sound from the bar file, the returned pointer is NULL. This is the reason of power cycle. For the image, as I mentioned before, calling ISHELL_LoadImage() to load bmp file directly solve the problem. But for sound, I can't find a solution. Plus, is there other way to load resource without having to load too many files on the handset?
Thanks!

Thanks! But I think my problem is a little different. Whether I use ISHELL_LoadResImage() to load an image from the bar file or use ISHELL_LoadResDataEx() to load sound from the bar file, the returned pointer is NULL. This is the reason of power cycle. For the image, as I mentioned before, calling ISHELL_LoadImage() to load bmp file directly solve the problem. But for sound, I can't find a solution. Plus, is there other way to load resource without having to load too many files on the handset?
Thanks!

You're doing something wrong, plain and simple. There are no general problems with loading data out of a BAR file, and if your calls fail then it's a problem related to something in your application. You may be out of memory - remember the Nokia has only 256 kB of usable RAM - or you may pass incorrect parameters, or parameters that are improperly initialized, etc. It would be foolish to simply discard loading data from the BAR file becasue of the problem. You need to find the root of the problem, not a work-around.

You're doing something wrong, plain and simple. There are no general problems with loading data out of a BAR file, and if your calls fail then it's a problem related to something in your application. You may be out of memory - remember the Nokia has only 256 kB of usable RAM - or you may pass incorrect parameters, or parameters that are improperly initialized, etc. It would be foolish to simply discard loading data from the BAR file becasue of the problem. You need to find the root of the problem, not a work-around.

My application works fine on several other handsets. But Nokia 6585 is the only one that uses big endian system. Is there any difference in the parameters between Nokia 6585 and those handsets that use little endian system?
Thanks!

My application works fine on several other handsets. But Nokia 6585 is the only one that uses big endian system. Is there any difference in the parameters between Nokia 6585 and those handsets that use little endian system?
Thanks!

No, it's the same. The only problem is if you're reading a datafile from the BAR file that contains data in little endian. In that case you will have to change the endianness of those data before using them in your application, evidently.

No, it's the same. The only problem is if you're reading a datafile from the BAR file that contains data in little endian. In that case you will have to change the endianness of those data before using them in your application, evidently.

How can I know if a datafile contains data in little endian?

How can I know if a datafile contains data in little endian?

Whenever you read data from a file and you access them as ints or shorts you will have to be very careful because that's where the endianess comes into play.

Whenever you read data from a file and you access them as ints or shorts you will have to be very careful because that's where the endianess comes into play.

gdw wrote:How can I know if a datafile contains data in little endian?
If you compiled (or build the .bar) of the data on a Windows or Linux machine, its in LittleEndian.

gdw wrote:How can I know if a datafile contains data in little endian?
If you compiled (or build the .bar) of the data on a Windows or Linux machine, its in LittleEndian.

Then how can I build the .bar file so that it is in big endian? Or do I have to make the .bar file in big endian in order to run the application on this handset?
Thanks!

Then how can I build the .bar file so that it is in big endian? Or do I have to make the .bar file in big endian in order to run the application on this handset?
Thanks!

What keless is saying is a bit misleading and not entirely true. BAR files are alsways little endian and have to be for the handsets to read them. The data that you put INTO the BAR file are what make the difference and depending where these data come from they may be big or little endian.
Just for the record even on Windos machines you can easily build big endian data files and Java does it by default for example. Therefore typically when you have datafiles that come from a J2ME application they are big endian and need to be converted into little endian - either in the file or during load-up.
So once again to answer your question how to know what format the file is in, it depends on where your data files come from.

What keless is saying is a bit misleading and not entirely true. BAR files are alsways little endian and have to be for the handsets to read them. The data that you put INTO the BAR file are what make the difference and depending where these data come from they may be big or little endian.
Just for the record even on Windos machines you can easily build big endian data files and Java does it by default for example. Therefore typically when you have datafiles that come from a J2ME application they are big endian and need to be converted into little endian - either in the file or during load-up.
So once again to answer your question how to know what format the file is in, it depends on where your data files come from.