You Are Here:

Community: Developer Discussion Boards

#1 Old drawPixels and getPixels - use int[], byte[] or short[] ?? - 2004-01-13, 15:08

Join Date: Aug 2003
Posts: 68
jhodgski
Offline
Regular Contributor
I have created a canvas object which is using loads of memory, resulting in an "Unable to run application" alert displaying, or the emulator (7210) just freezing.

So I'm going thru my code to try and improve things.

Firstly, I am creating some images with DirectGraphics's getPixels and drawPixels method. I am currently using these with short arrays (as advised), but wouldn't it be better to use int arrays?

Also, I am loading a few small PNG's. These could possibly be created in the application instead, but would doing this be a good or bad thing in terms of memory usage?

Any other suggestions most appreciated.

Cheers,
James
Reply With Quote

#2 Old 2004-01-13, 15:20

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Quote:
Firstly, I am creating some images with DirectGraphics's getPixels and drawPixels method. I am currently using these with short arrays (as advised), but wouldn't it be better to use int arrays?
What kind of array depends on the supported color format(s) on the phone. But if you're running out of memory why do you think an int (4 bytes) is better that a short (2 bytes)?
Quote:
Also, I am loading a few small PNG's. These could possibly be created in the application instead, but would doing this be a good or bad thing in terms of memory usage?
If the resulting images are the same size they will take up the same amount of memory at runtime.

shmoove
Reply With Quote

#3 Old 2004-01-13, 15:45

Join Date: Aug 2003
Posts: 68
jhodgski
Offline
Regular Contributor
Shmoove,

(Sorry, I meant to say wouldn't it be better to use *byte* arrays rather than short arrays.)

Am I right in assuming that most/all colour phones would support TYPE_BYTE_332_RGB - in which case I could use byte arrays ??

NB - I've drastically improved the memory probs by calling System.gc() at the beginning and end of the paint() method.

Thanks,
James
Reply With Quote

#4 Old 2004-01-13, 16:33

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
I don't know about that. You probably can't count on it. The only way I know to find if the phone supports the format is by trying to use drawPixels() and catching an IllegalArgumentException (anyone know any documents with this information??). But one thing is for sure: if you don't use the phones native pixel format your performance will drop since the function will have to convert the array to the native format before it can draw it.
Here's a quote from the Nokia javadocs:
Quote:
public int getNativePixelFormat()
Returns the native pixel format of an implementation. The method returns the pixel format, for example, TYPE_BYTE_1_GRAY or TYPE_USHORT_4444_ARGB. The native format is the most efficient format supported by the drawPixels and getPixels methods of specific implementation. An implementation must support the format that it returns from this method. Implementation may support also other pixel formats.
Notice that it says: "may support also other pixels formats". There are no guaranties.

shmoove
Reply With Quote

#5 Old 2004-01-13, 16:35

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
And as far as I know the native pixel format on most phones is TYPE_USHORT_4444_ARGB (all the 4096 color models).

shmoove
Reply With Quote

#6 Old 2004-01-13, 18:03

Join Date: Aug 2003
Posts: 68
jhodgski
Offline
Regular Contributor
according to getNativePixelFormat(), for the 7210 emulator it's TYPE_USHORT_444_RGB (444).
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

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ