You Are Here:

Community: Developer Discussion Boards

#1 Old Rotation question using DirectGraphics - 2004-01-30, 11:59

Join Date: Sep 2003
Posts: 60
smb101
Offline
Regular Contributor
I can easily rotate my image at coords 0,0 but what if I want to rotate at coords 16,0?

I tried the following...

dg.drawImage(myImage, x - (frame*frameWidth), y, dg.TOP|g.LEFT, 90);

.. but this performs the rotation first then does the translation.

Thanks.
Reply With Quote

#2 Old 2004-01-30, 13:42

Join Date: Jan 2004
Posts: 82
Location: Mumbai,India
ankur_k
Offline
Regular Contributor
Instead of this
dg.drawImage(myImage, x - (frame*frameWidth), y, dg.TOP|g.LEFT, 90);

Try this if it can solve your problem
dg.drawImage(myImage, x - (frame*frameWidth), y, g.TOP|g.LEFT, DirectGraphics.ROTATE_90);
Reply With Quote

#3 Old 2004-01-30, 14:49

Join Date: Sep 2003
Posts: 60
smb101
Offline
Regular Contributor
Hi,

I tried your suggestion but this has the same effect.

For example, if myImage consists of two 16*16 frames: one at 0,0 and the other at 16,0. The drawImage function seems to rotate the whole image(both frames) first so the frame that was at 16,0 is no longer there because of the 90 degree counter-clockwise rotation.
Reply With Quote

#4 Old 2004-01-30, 14:52

Join Date: Mar 2003
Posts: 61
Location: Merseyside
EvilCartman
Offline
Regular Contributor
I think it only ever rotates the image, it doesn't translate then rotate about a point. If thats what your trying to do.
you'd have to write your own code to do that i imagine, plus your limited to 90 degree rotations with directgraphics.
Reply With Quote

#5 Old 2004-01-30, 17:49

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Of course it rotates the whole image. It doesn't know that it is composed of frames. So the code is really just doing what you ask of it.
You have 2 choices:
1) Break the frames up so that each one is in it's own image.
2) Take the fact that the whole image is rotated into consideration when you draw it:
Code:
// after the rotation the second frame is at (0,16)
// and not at (16,0), so you have to offset the
// y coordinate instead of the x
dg.drawImage(myImage, x, y - (frame*frameWidth), g.TOP|g.LEFT, DirectGraphics.ROTATE_90);
shmoove

[edit]
Another thing to consider is that if you rotate 180 or 270 degrees the order of the frames will be reversed, so you're offset would be ((totalFrames - frame) * frameWidth).
[/edit]
Reply With Quote

#6 Old 2004-02-02, 12:59

Join Date: Sep 2003
Posts: 60
smb101
Offline
Regular Contributor
Thanks shmoove.

Option 2 worked a treat!
Reply With Quote

#7 Old 2004-09-03, 11:10

Join Date: Aug 2004
Posts: 6
Location: UK
nitrome
Offline
Registered User
Does anyone know if the MIDP 2.0 drawRegion() method works in a similar way? Does it rotate the whole image or just the region that you are trying to draw?
Reply With Quote

#8 Old 2004-09-04, 13:48

Join Date: Jan 2004
Posts: 82
Location: Mumbai,India
ankur_k
Offline
Regular Contributor
It does rotate the complete image.
Reply With Quote

#9 Old 2004-09-05, 12:06

Join Date: Aug 2004
Posts: 6
Location: UK
nitrome
Offline
Registered User
Actually I've figured it out since then - drawRegion just seems to rotate the region of the image that you specify! It must select the region of the image first and then just rotate that part.
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