Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User omarhassan123's Avatar
    Join Date
    Jun 2010
    Posts
    18
    Hi all,

    i need to rotate a j2me image with any angle like (10,30,50,110,200........... etc),

    any one can help on this?

    thanks a lot,
    Omar

  2. #2
    Registered User omarhassan123's Avatar
    Join Date
    Jun 2010
    Posts
    18
    Hi all,

    No Help?

  3. #3
    Nokia Developer Champion balagopalks's Avatar
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,427
    Rotating Images in Java ME


    A quick search could have helped you rather than waiting..

    Regards
    Gopal

  4. #4
    Registered User omarhassan123's Avatar
    Join Date
    Jun 2010
    Posts
    18
    Hi all,

    I made rotation by any angle in J2me i found this on a tutorial and i made set of enhancements on it.
    If any one need to try it here it is:

    public Image rotate(Image imgSource, int cx, int cy, double theta, int dd[]) {
    if (Math.abs(theta % 360) < 0.1) {
    return imgSource;
    }
    int w1 = imgSource.getWidth();
    int h1 = imgSource.getHeight();
    int srcMap[] = new int[w1 * h1];
    imgSource.getRGB(srcMap, 0, w1, 0, 0, w1, h1);
    int dx = cx;
    int dy = cy;
    double dr = Math.sqrt(dx * dx + dy * dy);
    int wh2 = (int) (2 * dr + 1);
    int destMap[] = new int[wh2 * wh2];
    double radian = theta * Math.PI / 180;
    for (int i = 0; i < w1; i++) {
    for (int j = 0; j < h1; j++) {
    int destX = (int) (dr + (i - cx) * Math.cos(radian) + (j - cy) * Math.sin(radian));
    int destY = (int) (dr + (j - cy) * Math.cos(radian) - (i - cx) * Math.sin(radian));
    destMap[(int) wh2 * destY + (int) destX] = srcMap[j * w1 + i];
    destMap[(int) wh2 * (int) destY + (int) destX + 1] = srcMap[j * w1 + i];
    }
    }
    dd[0] = (int) (cx - dr);
    dd[1] = (int) (cy - dr);
    return Image.createRGBImage(destMap, wh2, wh2, true);
    }

    thanks a lot
    Last edited by omarhassan123; 2010-08-08 at 14:03.

  5. #5
    Registered User sachin_t14's Avatar
    Join Date
    Sep 2009
    Posts
    4
    Hi Omarhassan,

    Nice method.... I tried & it worked. Just need to know what are the parameters cx & cy. No use of dd int array.

    Thanks a lot

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,682
    Quote Originally Posted by sachin_t14 View Post
    Just need to know what are the parameters cx & cy.
    It seems to be the centre of rotation
    No use of dd int array.
    Check once more, it is an output argument and is set at the end. Contains the new top-left coordinates for the image.

Similar Threads

  1. Rotation of an image
    By anothertest in forum Qt
    Replies: 4
    Last Post: 2010-07-22, 17:19
  2. Rotation of PNG image --> Blurred
    By deepchand86 in forum Symbian C++
    Replies: 20
    Last Post: 2008-09-25, 13:50
  3. create image rotation on top of screen
    By mohd_izzuan in forum Mobile Java General
    Replies: 3
    Last Post: 2006-05-05, 19:48
  4. Image Rotation At any Angle
    By indianstud2k2 in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2005-04-05, 17:48
  5. image rotation in Seimens
    By gaziani007 in forum Mobile Java General
    Replies: 3
    Last Post: 2005-01-28, 15:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved