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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:14:01+00:00 2026-05-24T11:14:01+00:00

For Bitmaps drawn with simple (x,y) coordinates, float _x = x – (bitmap.getWidth() /

  • 0

For Bitmaps drawn with simple (x,y) coordinates,

float _x = x - (bitmap.getWidth() / 2);
float _y = y - (bitmap.getHeight() / 2);
canvas.drawBitmap(bitmap, _x, _y, null);

I can detect if the bitmap has been touched.

I’m drawing a bitmap to the screen with

    dest = new Rect(0,0,0,0);
    src = new Rect(0,0,0,0);
    mSpriteHeight = (int) (sprite_pixel_height * mScale + 0.5f);
    mSpriteWidth = (int) (sprite_pixel_width * mScale + 0.5f);
    src.top = 0;
    src.left = 0;
    src.bottom = mSpriteHeight;
    src.right = mSpriteWidth;
    dest.top = (int) (_x * mScale);
    dest.bottom = (int) ((_x + mSpriteHeight) * mScale);
    dest.left = (int) (_y * mScale);
    dest.right = (int) ((_y + mSpriteWidth) * mScale);
    canvas.drawBitmap(bitmap, src, dest, null);

trying to incorporate the
screen density because “This function ignores the density associated with the bitmap. … so must already have the appropriate scaling factor applied.”

I haven’t been able to detect touches to the translated bitmaps. I must need to do a similar translation using mScale, but I’m lost.

Is there a better way to define the src and dest in my original canvas.drawBitmap(bitmap, src, dest, null);?

Anyone know an example where this has been done? I can’t seem to find the right search terms to find such an example.

  • 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-24T11:14:01+00:00Added an answer on May 24, 2026 at 11:14 am

    It seems to me that the same method applies as for simple x,y coordinates. You simply need to use the coordinates and size of Rect dest to calculate whether the bitmap has been touched.

    In other words, you need to do something like this:

    public boolean picked(Rect dest, int touchX, int touchY) {
         if(touchX > dest.left && touchX < dest.left + dest.width() &&
            touchY > dest.top && touchY < dest.top + dest.height())
                return true;
         return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to make a simple program that has one BITMAP that is the
I'm new to Android. I am drawing bitmaps, lines and shapes onto a Canvas
I assign a mask to a simple MovieClip with a square Bitmap in it.
I have worked on a simple application. It application includes diffrent levels that can
I want to do something relatively simple: I want to create a Bitmap object
My simple application has google map with overlay. And a onDraw() method to place
I'm trying to create simple custom component that draws Bitmap. It works fine when
I'd like to implement a simple bitmap font drawing in Java AWT-based application. Application
I have a bitmap with a Rectangle object that is drawn on top of
How do I draw a bitmap to a DC, while rotating it by a

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.