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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:05:24+00:00 2026-06-13T17:05:24+00:00

I’m a noob to android and I am trying to implement the 9 Old

  • 0

I’m a noob to android and I am trying to implement the 9 Old Androids flakes demo into my app. However, when i change the the image resource from the image used by the demo to one of my choosing the app crashes and says IllegalArgumentException: width and height must be > 0. My logcat says the line where I createscaledbitmap and createFlake is causing the issue. I’m lost as why this is happening the demo image has a width of 75px x 90px and my image has a width of 166px x 72px. Any help is greatly appreciated.

FLAKE VIEW CLASS (Where i create Flake)

void addFlakes(int quantity) {
    for (int i = 0; i < quantity; ++i) {
        flakes.add(Flake.createFlake(getWidth(), droid)); //This line causes exception
    }
    setNumFlakes(numFlakes + quantity);
}

/**
 * Subtract the specified number of droidflakes. We just take them off the end of the
 * list, leaving the others unchanged.
 */
void subtractFlakes(int quantity) {
    for (int i = 0; i < quantity; ++i) {
        int index = numFlakes - i - 1;
        flakes.remove(index);
    }
    setNumFlakes(numFlakes - quantity);
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    // Reset list of droidflakes, then restart it with 8 flakes
    flakes.clear();
    numFlakes = 0;
    addFlakes(8); //This line causes exception
    // Cancel animator in case it was already running
    animator.cancel();
    // Set up fps tracking and start the animation
    startTime = System.currentTimeMillis();
    prevTime = startTime;
    frames = 0;
    animator.start();
}

FLAKE CLASS (Where I create scaled bitmap)

static Flake createFlake(float xRange, Bitmap originalBitmap) {
    Flake flake = new Flake();
    // Size each flake with a width between 5 and 55 and a proportional height
    flake.width = (int)(5 + (float)Math.random() * 50);
    float hwRatio = originalBitmap.getHeight() / originalBitmap.getWidth();
    flake.height = (int)(flake.width * hwRatio);

    // Position the flake horizontally between the left and right of the range
    flake.x = (float)Math.random() * (xRange - flake.width);
    // Position the flake vertically slightly off the top of the display
    flake.y = 0 - (flake.height + (float)Math.random() * flake.height);

    // Each flake travels at 50-200 pixels per second
    flake.speed = 50 + (float) Math.random() * 150;

    // Flakes start at -90 to 90 degrees rotation, and rotate between -45 and 45
    // degrees per second
    flake.rotation = (float) Math.random() * 180 - 90;
    flake.rotationSpeed = (float) Math.random() * 90 - 45;

    // Get the cached bitmap for this size if it exists, otherwise create and cache one
    flake.bitmap = bitmapMap.get(flake.width);
    if (flake.bitmap == null) {
        flake.bitmap = Bitmap.createScaledBitmap(originalBitmap, //This line causes exception
                (int)flake.width, (int)flake.height, true);
        bitmapMap.put(flake.width, flake.bitmap);
    }
    return flake;
}
  • 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-06-13T17:05:25+00:00Added an answer on June 13, 2026 at 5:05 pm

    Since the width of your image is larger than the height you need to basically reverse these three lines of code.

    flake.width = (int)(5 + (float)Math.random() * 50);
    float hwRatio = originalBitmap.getHeight() / originalBitmap.getWidth();
    flake.height = (int)(flake.width * hwRatio);
    

    to this

    flake.height = (int)(5 + (float)Math.random() * 50);
    float hwRatio = originalBitmap.getWidth() / originalBitmap.getheight();
    flake.width = (int)(flake.height * hwRatio);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.