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

  • Home
  • SEARCH
  • 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 6748115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:37+00:00 2026-05-26T12:31:37+00:00

I want use many bitmap for my game canvas. I can’t Recycle bitmaps, because

  • 0

I want use many bitmap for my game canvas.

I can’t Recycle bitmaps, because I have to use bitmaps for the whole section.

Do mention some guidelines to optimize the code to handle many bitmap also faster performance for my canvas based Game Application.

Currently i am using the following code to get bitmap from drawable resource,

    BitmapFactory.Options bfOptions=new BitmapFactory.Options();
    bfOptions.inSampleSize = 1;
    bfOptions.inDither=false;                     //Disable Dithering mode
    bfOptions.inPurgeable=true;                   //Tell to gc that whether it needs free memory, the Bitmap can be cleared
    bfOptions.inInputShareable=true;              //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
    bfOptions.inTempStorage=new byte[16 * 1024]; 

    myBitMap=BitmapFactory.decodeResource(getResources(),ID, bfOptions);

I am currently following this code for drawing in canvas.

the images are in sprite so while trying to load many sprite its giving problem.

In this code link MainGamePanel.java is what i am doing exactly . for bitmap decoding i use the above method.

  • 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-26T12:31:38+00:00Added an answer on May 26, 2026 at 12:31 pm

    For really useful optimization proposals it would be beneficial to know more details about what exactly you want to optimize (drawing speed, memory footprint) and the requirements which your game canvas should fulfill as well as which kind of images you want to draw (big, small, repetitive, can they be breaked down, is tiling possible).

    A few general thoughts which you could consider spring to my mind:

    • Are you sure, you can’t reuse your bitmaps? I think in most games this is somehow possible. Maybe you can divide your images further?
    • You can scale the images down (or, if possible use svg images through libsvg – see https://launchpad.net/libsvg-android for details)
    • If you want to optimize the time needed for drawing, preloading your images could improve that
    • You can use a drawing thread to draw your canvas instead of relying on android to redraw the view automatically. See SurfaceHolder.lockCanvas(…) and SurfaceHolder.unlockCanvasAndPost(…) for details on that.
    • If you really need excellent drawing speed, consider using open gl.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use bar chart in web application. I have searched many libraries
I have a form element I want to use in many forms, a standard
I have a class that I want to use in many test cases: require
I have a problem, I want to use local::lib; in a script. But because
I have sprite brick that I want to use many times in my parallax
I have a few classes that I want to use in many applications, so
I want to use many bars like this one in my app (i don't
I want to use the same style in many listviews. And in my style
i want use some data from a website with web service. i have a
I have a transaction log file in CSV format that I want use to

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.