You Are Here:

Community: Developer Discussion Boards

#1 Old Best Way to Draw Images? - 2007-09-27, 18:56

Join Date: Mar 2003
Posts: 316
Location: IL/USA
Send a message via AIM to earamsey Send a message via MSN to earamsey Send a message via Yahoo to earamsey Send a message via Skype™ to earamsey
earamsey
Offline
Regular Contributor
Hello people, first I list my environment then the question.

Environment -
Device: Nokia E61
OS: Symbian OS v9.1
Platform: S60 3rd Edition
Memory Card: 32MB minimum (I think)

The package "com.nokia.mid.ui.DirectGraphics" and "javax.microedition.lcdui.Graphics" both have methods for drawing images directly from byte arrays;

Nokia:
Code:
drawPixels(byte[] pixels,
           byte[] transparencyMask,
           int offset,
           int scanlength,
           int x,
           int y,
           int width,
           int height,
           int manipulation,
           int format)
MIDP2.0:
Code:
drawRGB(int[] rgbData,
        int offset,
        int scanlength,
        int x,
        int y,
        int width,
        int height,
        boolean processAlpha)
Now, I was wondering, does it save memory to draw images directly from a byte array rather than from Image objects? I ask because, I have an image intensive application and I have been encountering memory problems. My idea was to convert all of the images to byte arrays and place them into a resource file. The following steps would be carried out to draw a paricular image;

1.open resource file and use index table to offset of image
2.read the size of the byte array
3.create byte array of specified size
4.load image data read into array
5.now draw images using either "drawPixel()" or "drawRGB()" methods

If one were to use the traditional method it would require a call to "Image.createImage(String)" which allocates an Image object. I don't know the overhead for Image objects but i seems like it would need to subclass "Object" inadditon to the actual image data and it has static methods of which I don't know the cost in memory would be. One benefit I know from using byte arrays is that all of the images would be in one resource file which should compress very well. If the file is too large I can always compress it before I jar and decompress it as I read it's contents using a J2ME GZip library, freeware!, that I found on the Internet.

I don't know which of the two methods is better; Nokia's "drawPixel()" or MIDP's "drawRGB", however, I assume that "drawRGB()" pack RGB+Alpha into an integer. Which one is better of the two. When I say better it means requires less memory and draws the fastest?

Thanks!


Erica A Ramsey / Mobile Apps Developer /
Resume ~ http://home.comcast.net/~erica.ramsey/CV
Some Project Screenshots ~ http://home.comcast.net/~erica.ramsey/CV/screens.html
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
Incorrect rgb values for jpg images on S40 3rd ed bjudfar Mobile Java Media (Graphics & Sounds) 8 2007-05-29 17:34
Nokia 6682 doesn't draw images while playing video mac07 Mobile Java Media (Graphics & Sounds) 2 2007-04-05 19:31
Problem with PNG Images cyphre666 Mobile Java Media (Graphics & Sounds) 4 2003-12-12 19:20
Draw Images zhenLeow General Symbian C++ 1 2003-10-29 11:19
how draw more than 3 images with midp1.0? lightpop Mobile Java Media (Graphics & Sounds) 1 2003-07-31 10:25

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X 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