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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:53:25+00:00 2026-06-10T11:53:25+00:00

How does Google scale the Images in Google Maps, Am trying to create an

  • 0

How does Google scale the Images in Google Maps, Am trying to create an application where am using custom maps instead of Google maps. Everything is working well just this that I am not able to scale the images accordingly for phones with Dimension > 240 x 320, but for the phones with dimensions bigger than this crashes because I surpass the default heap size of an app in android and get java.lang.OutOfMemoryError: bitmap size exceeds VM budget. I just can’t figure out how should I scale Images according to the Resolution of the phone.

This is what am doing :

1) First am calculating the Width and height of the phone :

Display display = getWindowManager().getDefaultDisplay();
            Constatnts.SCR_WD = display.getWidth();
            Constatnts.SCR_HT = display.getHeight();

2) I have set an onclicklistener for the zoomIn button which calls the zoomout function :

public void zoomOut() {
        if (isloading > 5)
            return;
        System.gc();

        if (zoomLevel < 12) {
            dc = true;
            sc = true;
            emptyBuffer();
            zoom = -1;
            stopload = true;
            bitmapArr1 = new Bitmap[tilesyno][tilesxno];
            for (int i = 0; i < bitmapArr.length; i++) {// row
                for (int j = 0; j < bitmapArr[i].length; j++) {// coloum
                    if (bitmapArr[i][j] != null) {
                        int tmpTilewd = bitmapArr[i][j].getWidth() / 2;
                        int tmpTileHt = bitmapArr[i][j].getHeight() / 2;
                        Bitmap b = ExtraFunctions.ScaleBitmap(bitmapArr[i][j],
                                tmpTilewd, tmpTileHt);
                        if (bitmapArr1 != null)
                            bitmapArr1[i][j] = b;
                    }
                }
            }

            lastPressed1 = System.currentTimeMillis();
            setCenterLatLon();
            zoomLevel++;
            if (!isStarted)
                tryLoadMap();
        }
    }


void tryLoadMap() {
        if (isStarted)
            return;
        isStarted = true;
        Thread th = new Thread() {
            public void run() {
                try {
                    Thread.sleep(System.currentTimeMillis() - lastPressed1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                loadLocalMap();
                if (showDirection)
                    DirectionPath(lat, lon);

                if (isSearchAvail)
                    SearchPath(lat, lon, tmpselected);

                isStarted = false;
            }
        };
        th.start();
    }

For scaling :

        public static Bitmap ScaleBitmap(Bitmap bitmapOrg,int newWidth,int newHeight) {
    if(bitmapOrg==null)
        return null;

    int width = bitmapOrg.getWidth();
    int height = bitmapOrg.getHeight();
    // calculate the scale - in this case = 0.4f
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;

    // createa matrix for the manipulation
    Matrix matrix = new Matrix();
    // resize the bit map
    matrix.postScale(scaleWidth, scaleHeight);
    // rotate the Bitmap
    //matrix.postRotate(45);

    // recreate the new Bitmap
    return Bitmap
            .createBitmap(bitmapOrg, 0, 0, width, height, matrix, true);
}

LOgcat :

08-30 17:09:30.342: E/dalvikvm-heap(440): 1451808-byte external allocation too large for this process.
08-30 17:09:30.382: E/GraphicsJNI(440): VM won't let us allocate 1451808 bytes
08-30 17:09:30.382: D/AndroidRuntime(440): Shutting down VM
08-30 17:09:30.401: W/dalvikvm(440): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-30 17:09:30.442: E/AndroidRuntime(440): FATAL EXCEPTION: main
08-30 17:09:30.442: E/AndroidRuntime(440): java.lang.IllegalStateException: Could not execute method of the activity
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.view.View$1.onClick(View.java:2072)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.view.View.performClick(View.java:2408)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.view.View$PerformClick.run(View.java:8816)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.os.Handler.handleCallback(Handler.java:587)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.os.Looper.loop(Looper.java:123)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-30 17:09:30.442: E/AndroidRuntime(440):  at java.lang.reflect.Method.invokeNative(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440):  at java.lang.reflect.Method.invoke(Method.java:521)
08-30 17:09:30.442: E/AndroidRuntime(440):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-30 17:09:30.442: E/AndroidRuntime(440):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-30 17:09:30.442: E/AndroidRuntime(440):  at dalvik.system.NativeStart.main(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440): Caused by: java.lang.reflect.InvocationTargetException
08-30 17:09:30.442: E/AndroidRuntime(440):  at com.Map.zoomIn(MapScreen.java:762)
08-30 17:09:30.442: E/AndroidRuntime(440):  at java.lang.reflect.Method.invokeNative(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440):  at java.lang.reflect.Method.invoke(Method.java:521)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.view.View$1.onClick(View.java:2067)
08-30 17:09:30.442: E/AndroidRuntime(440):  ... 11 more
08-30 17:09:30.442: E/AndroidRuntime(440): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.graphics.Bitmap.nativeCreate(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
08-30 17:09:30.442: E/AndroidRuntime(440):  at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
08-30 17:09:30.442: E/AndroidRuntime(440):  at com.Map.ncore.XtraFunctions.ScaleBitmap(ExtraFunctions.java:32)
08-30 17:09:30.442: E/AndroidRuntime(440):  at com.Map.MapCanvas.zoomIn(MapCanvas.java:1018)
08-30 17:09:30.442: E/AndroidRuntime(440):  ... 15 more
08-30 17:14:30.522: I/Process(440): Sending signal. PID: 440 SIG: 9
  • 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-10T11:53:27+00:00Added an answer on June 10, 2026 at 11:53 am

    Hmmm what is bitmapArr[i][j]? Are those decoded Bitmaps? if so then you’re kind of missing the point. You should scale BEFORE reading them into bitmapArr. Otherwise you’re keeping a copy of both the originals and the downsampled ones, saving nothing (and in fact using more memory). You should not read the image from disk (or wherever it is) before knowing what size you want to downscale to.

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

Sidebar

Related Questions

I'm probably just being daft but my Google searches are not working out well.
I would like to upload files just like google mail does. I would want
Does Google Chrome Frame add CSS3 capabilities as well to IE ? One of
For a Christmas Market, I'm currently working on a Google Maps map. I load
Does Google cap the number of connections a server can make to Google IMAP
Does Google has a service similar to Yahoo! Placemaker: Developers specify structured and unstructured
Does Google have an API for registering hooks/callbacks for whenever a document is updated?
How does Google Chrome's ADVANCED REST CLIENT plugin make cross domain POST requests? I
How does Google Toolbar determine the language of a page to offer translation from
Why does Google prepend while(1); to their (private) JSON responses? For example, here's a

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.