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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:23:37+00:00 2026-05-23T09:23:37+00:00

I need an algorithm which will determine the maximum scale increase that is possible

  • 0

I need an algorithm which will determine the maximum scale increase that is possible for an image.

The rules (size limitation of a BitmapData object for the Flash Player, but this is not a Flash question):

  1. both the width and length of the image must be less than 8,191 pixels
  2. the maximum number of pixels in the image can not exceed 16,777,215

therefore, as mentioned in the documentation:

if a BitmapData object is 8,191 pixels
wide, it can only be 2,048 pixels
high.

In my code, I first determine if any of these rules are broken and throw and error if they are. this lets me know that any image that is loaded and does not throw an error has scalability.

The image I’m using is 2514 width x 1029 height. This image will not throw an error since both width and height are less than 8,191 and it’s pixel count, or width multiplied by height, is less than 16,777,215.

I identify as being right-brained and don’t have much confidence in my math skills, but the following is what I’ve come up with to determine the maximum allowed scale for the image.

private static const MAX_BITMAP_MEASUREMENT:uint = 8191;
private static const MAX_BITMAP_PIXELS:uint = 16777215;

var imageWidth:uint = 2514;
var imageHeight:uint = 1029;

var roughScaleUp:Number = 1.0 / Math.max(imageWidth, imageHeight) * MAX_BITMAP_MEASUREMENT;
var scaleBack:Number = Math.max(Math.min(imageWidth, imageHeight) * roughScaleUp - MAX_BITMAP_PIXELS / MAX_BITMAP_MEASUREMENT, 0);
var maxScale:Number = 1.0 / (Math.max(imageWidth, imageHeight) + scaleBack) * MAX_BITMAP_MEASUREMENT;

This code outputs the maximum scale for my image as 2.145144435977516, but I tested it and there is still a lot of pixel space remaining, so it should be able to be scaled up more and I’m pretty sure my code is terribly wrong.

Any math wizards on here care to help out a lowly art school graduate? I’m fully ready to accept that there is probably a much more simplistic solution to this problem and I’m prepared for the lashings.

  • 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-23T09:23:38+00:00Added an answer on May 23, 2026 at 9:23 am

    You have to multiply both the width and the height by a constant, and the scaled result of the multiplication should be less than 16777215.

    So

    a^2 * w * h == 16,777,215
    

    Which yields, for your values of w and h

    a = 2.5466520486244177 [= Sqrt(16,777,215 / (w*h)) ]
    

    So , for your values for the new w and h, you get:

    NewW = a * w = 6402.283250241786
    NewH = a * h = 2620.5049580345258  
    

    … just round them down 🙂

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

Sidebar

Related Questions

I need an example algorithm that will draw pixels one at a time on
I need an algorithm which generates all possible combination of a set number and
I need an algorithm which given a list L and a number N ,
I need help regarding DDA algorithm , i'm confused by the tutorial which i
I need an algorithm to determine if a sentence, paragraph or article is negative
I need to find an algorithm which determines a relationship between a square and
I need to write a program which will deskew scanned images. I've chosen Qt
I was wondering if anybody could point me to the best algorithm/heuristic which will
I need the algorithm to animate the arrow based on 2 parameters, angle while
I need effective algorithm to keep only ten latest files on disk in particular

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.