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 8432147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:02:50+00:00 2026-06-10T06:02:50+00:00

Okay, I have a method that takes the variables: an image, int x, int

  • 0

Okay, I have a method that takes the variables: an image, int x, int y, float angle.

I am using a canvas, and I am using a Matrix transform = new Matrix(); to rotate the image at it’s center. However, I want the image to be drawn at the coordinates of x and y. For some reason, all the different methods I have used have not worked. Sometimes it draws it at 0,0 or it doesn’t even show up on the screen.

Here’s my pseudo-code:

//pseudo-code: img_width, img_height
public void drawImage(Bitmap img, int x, int y, float angle)
{
    transform.setTranslate(x, y);
    transform.setRotate(angle, img_width/2, img_height/2);
    canvas.drawBitmap(img, transform, null);
}

I have gotten the image to rotate, but I want the image to be drawn at the specified coordinates: x,y.

I have tried swapping all the variables, used transform.preRotate, and basically spent 1 hour trying to figure out why nothing will work. I have lots of other images being drawn to the canvas, and they appear where they should, but when I want to rotate, it won’t draw at the specified coordinates.

I’ve read about 5 SO questions and answers related to this, but none give me what I need.

I really need an answer and code urgently, thank you.

  • 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-06-10T06:02:51+00:00Added an answer on June 10, 2026 at 6:02 am

    Maybe you’d want to write :

    public void drawImage(Bitmap img, int x, int y, float angle)
    {
      transform.setRotate(angle, img_width/2, img_height/2);
      transform.postTranslate(x, y);
      canvas.drawBitmap(img, transform, null);
    }
    

    If you translate the image before the rotation, the image won’t go where you expect it to…

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

Sidebar

Related Questions

Okay, so I want to have a generic method that can read data from
Okay so let's say I have class A... CLASS A has a method that
Okay, often I'll have a method that returns a Set of some sort. The
Okay I have a large CRUD app that uses tabs with Forms embedded in
okay i have found the way to run a video in a image.... the
Okay I have updated my code quite a bit. I am getting a new
I have a method that asynchronously downloads images. If the images are related to
I have a method in C# 4.0 that is like this: protected override bool
Okay - so I know it's simple to build a factory method that provides
EDIT: Sorted. See bottom for solution Okay, I have to write a program that

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.