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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:15:43+00:00 2026-06-18T01:15:43+00:00

I want to draw the 2000 points which save to data object. I use

  • 0

I want to draw the 2000 points which save to data object.

I use the following code:

Bitmap bitmap = Bitmap.createBitmap(2000,100,Config.ARGB_8888);
Canvas canvasTemp=new Canvas(bitmap);
Paint paint=new Paint();
for (int i = 0; i < 2000; i++) {
canvasTemp.drawPoint(i, data.getData(i), paint);
}
   Matrix matrix = new Matrix(); 
    float scaleWidth = ((float) 640 / 2000);   
float scaleHeight = ((float) 480/ 100);   
matrix.postScale(scaleWidth, scaleHeight);   
 Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0,2000, 100, matrix, true);   
canvas.drawBitmap(newbmp, 0, 0, new Paint());

This drawing speed is too slow. It needs about 5 or 6 seconds.

How to make the drawing speed more quickly?

  • 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-18T01:15:44+00:00Added an answer on June 18, 2026 at 1:15 am

    Why not directly paint on the canvas? It saves you creating two (large) bitmaps:

    Paint paint=new Paint();
    Matrix matrix = new Matrix(); 
    float scaleWidth = ((float) 640 / 2000);   
    float scaleHeight = ((float) 480/ 100);   
    matrix.postScale(scaleWidth, scaleHeight);   
    canvast.concat(matrix);
    for (int i = 0; i < 2000; i++) {
      canvas.drawPoint(i, data.getData(i), paint);
    }
    

    Just use concat() to scale the draw commands of the canvas.

    Additional note: Creating new objects (paint, matrix, two large! bitmaps) in the draw method of a View is not recommended. It results in lots of instance creations/deletions, which result in activating the garbage collector (GC) more often, resulting in (huge) performance issues with your application!

    Instead, create the paint and matrix object once, in the constructor of your View.

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

Sidebar

Related Questions

I want to draw many geo points with Leaflet. Therefore I want to use
I want to draw an area from given points on a map using the
i want to draw line, i have two textfiled in which i enter some
Want to draw an UIImageView which has an CGImage, and the UIImageView has alpha
I want to draw the background of a UITableViewCell which has a grouped style.
I want to have a PHP code to draw some ids one by one
I want to draw an alpha mask image in code. Right now I do:
The following is my code: <svg xmlns:xlink=http://www.w3.org/1999/xlink xmlns=http://www.w3.org/2000/svg width=1200px height=1500px viewBox=0 0 400 500
I want to draw my stage as a new bitmap. How can I cut
I want to draw a continuous line through coordinate points I have stored in

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.