Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7628505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:36:12+00:00 2026-05-31T05:36:12+00:00

I searched through this site to find out how to rotate a image back

  • 0

I searched through this site to find out how to rotate a image back and forth and came up with my own with the help of other post on this site, it works great, the only problem is now I got it working so it rotates back and forth the way I like it, how the heck do I now position it on the screen?
heres the code so far:

 private Bitmap ray;
    private  int mRot = -33;
    private boolean goRight = true;

    void onRotDraw(Canvas canvas)
    {
        int width = ray.getWidth();
        int height = ray.getHeight();

        if (mRot > 30){
            goRight = false;
        }
        if (mRot < -30){
            goRight = true;
        }
        if (goRight){
            mRot += 1;
        }else
        {
            mRot -= 1;
        }
               canvas.rotate(mRot,width / 2,height / 2);
               this.Draw_Sprite(canvas, 0, mRot ); 

    }

    public void Draw_Sprite(Canvas c, int whatever, int rot) {  
        //rotating image back and forth
        int width = ray.getWidth();
        int height = ray.getHeight();
         Rect src = new Rect(width - width, height - height, width, height);
         Rect dst = new Rect(width - width, height - height,   width,  height); 
         c.drawBitmap(this.ray, src, dst, null);
    }

Usually with drawBitmap I use it to position my images but this one uses the src and dst instead for the size of the rectangle, so now it works great but how would I change the position on the screen from 0,0 to where I want it to go?

this was taken partially or mostly from this post:
Sprite Rotation in Android using Canvas.DrawBitmap. I am close, what am I doing wrong?

Which gave me all I needed to get this going except how to set the x and y position on the screen, any help with this would be greatly appreciated, I’ve been wrecking my brains out trying to find a way to get this set the x and y positions with no luck and its probably something simple.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:36:13+00:00Added an answer on May 31, 2026 at 5:36 am

    This is a piece of code from that other post you referenced:

    Rect src = new Rect(0, 0, width, height);
    Rect dst = new Rect(x, y, x + width, y + height);
    

    It’s the x and y in the dst Rect that determine the location of the bitmap.

    Your code:

    Rect src = new Rect(width - width, height - height, width, height);
    Rect dst = new Rect(width - width, height - height,   width,  height);
    

    Is going to always draw it at 0, 0 because width – width will be 0 and height – height will be 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched through the web and what I've found out is this: To make
I've searched online and on this site and I can not find a good
I think I searched thoroughly this site, but could not find answer to my
I've searched through several suggestions on this site and haven't quite been able to
I've been working forever on this, and searched through all the other examples and
I searched through internet and this site as well but haven't found the answer.
I have searched this site and Google and even though the idea is pretty
I have searched through many times but have not seen this before. Probably really
i searched through Stack overflow but fail to find a solution in regards to
I've searched through the other expected Class Name error questions on here, but they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.