You Are Here:

Community: Developer Discussion Boards

#1 Old Reading subsets of an image - 2003-07-24, 17:56

Join Date: Jul 2003
Posts: 21
pjmlp
Offline
Registered User
I am developing a game and would like to use a png image with all the required tiles for the game.

However, looking to the J2ME(MIDP 1.0) and Nokia UI, I don't find a way to copy a subset of the image to the screen.

Basically I would like to do some form of blitting where I give the source and destination rectangle for the blit.

Thanks in advance,
Paulo Pinto
Reply With Quote

#2 Old 2003-07-24, 18:18

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
If you don't care about a little less speed then you can use a clipping method:
http://nkn.forum.nokia.com/forum/sho...ove+setclip%2A
If you want to keep the speed but don't care about losing transparency then you can create new smaller images from the big one:
Code:
Image newImage = Image.createImage(newWidth,newHeight);
newImage.getGraphics().drawImage(original,-xOffsetOfTheNewImageInTheBigOne,-sameForYOffset,Graphics.TOP|Graphics.LEFT);
If you want to keep transparency, then you'll need to look into DirectGraphics and it's methods from the Nokia UI API.

shmoove
Reply With Quote

#3 Old 2003-07-25, 10:55

Join Date: Jul 2003
Posts: 21
pjmlp
Offline
Registered User
Thanks I will have a look into it.
Reply With Quote

#4 Old 2003-09-01, 16:37

Join Date: Mar 2003
Posts: 8
dfun
Offline
Registered User
I had already figured out on my own the negative arguments trick for drawImage, and it has been working fine on a Nokia 7210: to create a new w x h image that contains a w x h clip of a bigger image, starting at (startX, startY) on the bigger image, you simply create the new w x h image, get a Graphics for it, and then call drawImage(sourceImage, -startX, -startY, Graphics.TOP | Graphics.LEFT).

However, I have now started porting the application on a Nokia 3410 and it seems this is not working any more - sometimes I only get a few lines of the original image copied and the rest left blank. (For now, I have just tried it with the 1.0 emulator - not on the phone yet.)

Does anyone (maybe from Nokia staff) know whether calls to Graphics.drawImage with negative values for the x and y parameters are valid and supported on all Nokia phones? Or does anyone know an alternate solution in MIDP 1.0?
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