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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:27+00:00 2026-05-27T04:05:27+00:00

I like to resize an bitmap,if it is big make it small and place

  • 0

I like to resize an bitmap,if it is big make it small and place it on an specific location in the surface view, I need to get device width and height and then bitmap size and place them in an surface view and then take another image resize it and place it in any location has i like.
How to know the location co ordinates first(to place second image – this should be device independent if larger/smaller screen layout should not change)

and how to scale an big bitmap and set as background so i can draw an image over it.
my code :

final int canvasWidth = getWidth();
final int canvasHeight = getHeight();

int imageWidth = img.getWidth();
int imageHeight = img.getHeight();

float scaleFactor = Math.min( (float)canvasWidth / imageWidth, 
                              (float)canvasHeight / imageHeight );
Bitmap scaled = Bitmap.createScaledBitmap(  img, 
                                            (int)(scaleFactor * imageWidth), 
                                            (int)(scaleFactor * imageHeight), 
                                            true );
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(scaled, 10, 10, null);

this scale the big image but it doesn’t fit the whole screen “img – bitmap is like an background image “

Someone can help me to understand the resize basics (I’m new so finding hard to understand resizing) to resize image to fit screen and resize any image to smaller one and place it in any location i like .

  • 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-27T04:05:28+00:00Added an answer on May 27, 2026 at 4:05 am

    Store your bitmap as a source for manipulation and display it using ImageView:

    Bitmap realImage = BitmapFactory.decodeFile(filePathFromActivity.toString());
    
    Bitmap newBitmap = scaleDown(realImage, MAX_IMAGE_SIZE, true);
    
    
    imageView.setImageBitmap(newBitmap);
    
    
    //scale down method
    public static Bitmap scaleDown(Bitmap realImage, float maxImageSize,
            boolean filter) {
        float ratio = Math.min(
                (float) maxImageSize / realImage.getWidth(),
                (float) maxImageSize / realImage.getHeight());
        int width = Math.round((float) ratio * realImage.getWidth());
        int height = Math.round((float) ratio * realImage.getHeight());
    
        Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
                height, filter);
        return newBitmap;
    }
    

    And set your ImageView’s width and height to “fill_parent“.

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

Sidebar

Related Questions

I need a method that resizes an any kind of image like bitmap, jpeg,
I would like to resize the topmost windows. I have small problem in the
I would like to resize images on server side to make thumbnail dynamicaly. I'm
I'd like to make a simple VB utility to resize images using vb.net. I
I would like to resize a Java BufferedImage, making it smaller vertically but without
I have a directory full of images that I would like to resize to
I would like to have a resize indication on a windows forms Form (the
I'd like to have ability to resize pictures on my site. Algorithm: You upload
I would like to have a Java component which has a resize icon on
i want to resize the font of all elements of a page like user

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.