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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:07:17+00:00 2026-05-29T11:07:17+00:00

On drawing on canvas if i use this code to draw the bitmap then

  • 0

On drawing on canvas if i use this code to draw the bitmap then it get stratched.

Code1:

photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true); // original

But if i use below code to draw the bitmap then the Bitmap not getting stratched but i m only getting the some portion of top left corner of the Image.

Code2:

photoBitmap = Bitmap.createBitmap(tempBitmap);

Now, Above both code is for creating/getting the bitmap. and to draw the Bitmap on canvas i use below code:

canvas.drawBitmap (photoBitmap,0,  0, null);// Original Without ImageView

Now, What should i do to saw full image and it should not get stratch.

Thanks.

  • 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-29T11:07:18+00:00Added an answer on May 29, 2026 at 11:07 am

    It sounds like what you’re asking to do is to stretch the bitmap in both directions equally so that it fits on the display. Try this:

            float xscale = (float)display.getWidth() / (float)tempBitmap.getWidth();
            float yscale = (float)display.getHeight() / (float)tempBitmap.getHeight();
            if (xscale > yscale) // make sure both dimensions fit (use the smaller scale)
               xscale = yscale;
            float newx = (float)tempBitmap.getWidth() * xscale;
            float newy = (float)tempBitmap.getHeight() * xscale; // use the same scale for both dimensions
            // if you want it centered on the display (black borders)
            float borderx = ((float)display.getWidth() - newx) / 2.0;
            float bordery = ((float)display.getHeight() - newy) / 2.0;
            photoBitmap = Bitmap.createScaledBitmap(tempBitmap, newx, newy, true);
    
            // your drawing code will now look like this
            canvas.drawBitmap (photoBitmap, borderx,  bordery, null); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to draw a triangular canvas. But I can't manage to
I want use many bitmap for my game canvas. I can't Recycle bitmaps, because
I would like to use Canvas to shift a bitmap; to create a Bitmap
I tried to use the canvas tag to allow users to draw shapes, but
I am drawing a concave shape in canvas using the following code: var ctx
I am drawing bitmaps on the canvas using bitmap factory(see P.S.). I also have
I am using a large JS library to perform certain drawing operations in canvas.
I'm drawing a whole bunch of Polygons onto a canvas, most of which share
I'm drawing a selection box when I click and drag on my canvas object
I have recently focused on drawing some cool shapes in a HTML 5.0 canvas.

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.