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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:55:46+00:00 2026-05-28T16:55:46+00:00

Hello great people of stackoverflow.com, I have a stumbled upon a great difficulty in

  • 0

Hello great people of stackoverflow.com, I have a stumbled upon a great difficulty in my code; that being not being able to resize my images in-line with my screen size.

I have an image that is SAY 65 pixels by 65 pixels but I want this image to be a certain percentage of the screen say 6% while keeping square.

My brain cannot process the mathematics for this (because it is slow 🙁 )

(_width & _height is the screen width and height)

What I’ve got so far is:

int width = bitmap.getWidth();
int height = bitmap.getHeight();

int avg_screen_dimension = (_width + _height) / 2;

float scaleWidth =
    ((float) width + (avg_screen_dimension - _width)) / width;
float scaleHeight =
    ((float) height + (avg_screen_dimension - _height)) / height;

// CREATE A MATRIX FOR THE MANIPULATION
Matrix matrix = new Matrix();

// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);

// RECREATE THE NEW BITMAP

Bitmap resizedBitmap =
    Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);

return resizedBitmap;

Any help would be greatly appreciated!

  • 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-28T16:55:47+00:00Added an answer on May 28, 2026 at 4:55 pm

    It’s little more than simple algebra – no complex math needed.

    You’ll have to choose between fraction of the width or height of your screen, unless they’re equal.

    Let h = screen height, w = screen width, f = fraction of screen dimension, x = image size.

    Then x = h*f. If you want to make it a fraction of the width, substitute w for h.

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

Sidebar

Related Questions

Hello again great knowledge masters of stackoverflow, once again the small coder apprentice tabaluga
Hello all at StackOverflow.. Reasonably new to this site, but I have had nothing
Hello Great community of SO! I have created a GUI application with qt and
Hello good people of Stack Overflow, I am having great troubles with designing a
Here is this great plugin: http://thrivingkings.com/apprise/ When I use apprise('Hello'); or other function it
hello guys i have one simple program which copying itself. Its work great when
Hello, I have the following sql table + data: CREATE TABLE IF NOT EXISTS
I have this code in as2, it works great, but I need to adapt
Hello I have a select element which has a few options. I am able
I have the following data: A post called Hello has categories greet Another post

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.