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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:10:44+00:00 2026-06-07T01:10:44+00:00

If you always have to draw the same rectangle, it is faster to do

  • 0

If you always have to draw the same rectangle, it is faster to do it with a static bitmap or with canvas.drawRect()?

For this example, the are four layered rectangles. So a boarder with a fill color, and then a boarder between a middle color and the fill color.

So four paint.setColor() commands and four canvas.drawRect commands or one canvas.drawBitmap().

  • 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-07T01:10:46+00:00Added an answer on June 7, 2026 at 1:10 am

    I strongly recommend drawRect().

    Bitmaps take up a huge chunk of memory, and can lead to Out Of Memory Exceptions if not used correctly.

    Written by android:

    Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the camera on the Galaxy Nexus takes photos up to 2592×1936 pixels (5 megapixels). If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.

    To prevent headache, and unexpected crashes. Use drawRect();

    If you are doing these 4 draws on a regular basis for different objects, consider writing a method that does all 4 for you. So you are not causing massive repetition.

    For example:

    public void DrawMyRect(Canvas canvas, int x, int y)
    {
       canvas.drawRect(x, y ,x + 15, y + 40, paint);
       // Draw its line etc etc..
     }
    

    Alternatively, if you do go for drawing bitmap, as it does have advantages:

    See this epic Link by Android, on how to properly use Bitmaps

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

Sidebar

Related Questions

I always have trouble with complicated SQL queries. This is what I have $query
I know that immutable objects always have the same state, the state in which
It's really a pain, but always when I draw an UIImage in -drawRect:, it's
I'm starting to work with OpenGL in iOS. I have always learned to draw
I have a picture (bitmap) and I want to draw some shapes and rotated
As an example, I have the following draw function in some OpenGL application: void
I always have used Spring Framework classes as-is. However I am thinking of customizing
I always have trouble designing the user interface when it come to manage a
I have strings that use simple_format so they always have p tags surrounding them.
I would like to always have my model look to see if an object

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.