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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:05+00:00 2026-05-26T00:00:05+00:00

I am generating Bitmap object to show the sound waveform of a loaded sound.

  • 0

I am generating Bitmap object to show the sound waveform of a loaded sound. The bitmap is 1024×120 and after it has been generated I shrink its size to 655×120. My problem is the player that loads the bitmap in task manager becomes 260MB heavy.

I am also adding some gradients and I also cache it as bitmap, but if I remove this properties I dont get any big difference in size.

I also can try to small its size but still I think the bitmap will be big.

Any idea how to compress or whatever solution to solve this problem?

thanks

Here is some code

These are the sound and Bitmap settigns of the function that generate the bitmap.

   public function generateBitmap(snd:Sound):void 
    {
        samples = new ByteArray();
        buffer = new BitmapData(1024, 120, false, backColor);
        screen = new Bitmap(buffer);
        rect = new Rectangle(0, 0, 1, 0);
        var left:Number;
        var right:Number;

        screen.x = 0;
        screen.y = 0;
        screen.width = 655;
        screen.height = 120;

        buffer.fillRect( buffer.rect, backColor );

Now I am doing some samples extraction

        var extract:Number = Math.floor ((snd.length / 1000) * 44100);
        playingTime = snd.length;
        ratio = playingTime / buffer.width;

        var lng:Number = snd.extract(samples, extract);
        samples.position = 0;
        step = samples.length / 4096;

        do 
        {
            step-- ;
        }
        while ( step % 4 );

Follows the drawing method of the bitmap.

           for (var c:int = 0; c < 4096; c++)
        {
            rect.x = c / 4;
            left = samples.readFloat() * 25;
            right = samples.readFloat() * 25;
            samples.position = c * step;

            // left channel 
            if (left > 0)
            {
                rect.y = 30 - left;
                rect.height = left;
            } 
            else
            {
                rect.y = 30;
                rect.height = -left;
            }
            buffer.fillRect( rect, leftChColor );

            // right channel 
            if (right > 0)
            {
                rect.y = 80 - right;
                rect.height = right;
            } 
            else
            {
                rect.y = 80;
                rect.height = -right;
            }
            buffer.fillRect( rect, rightChColor );
        }
        screen.width = screenWidth;
        screen.height = screenHeight;
        addChild( screen );
        }

Here is a reference of the code I have used. Tried it without my stuff in the player and get 193MB of RAM just for the flash player. So the code needs I guess the code needs refinement. Any idea or othere method to do the same stuff without eating so much RAM?

  • 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-26T00:00:06+00:00Added an answer on May 26, 2026 at 12:00 am

    Before this line:

    buffer = new BitmapData(1024, 120, false, backColor);
    

    Add:

    if ( buffer ) { buffer.dispose(); buffer = null; }
    buffer = new BitmapData(1024, 120, false, backColor);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Generating inline JavaScript in HTML has always made me feel dirty and after having
I am generating a System.Drawing.Bitmap on the fly in an ASP.NET Custom Web Server
when generating python wrappers with swig the python wrapper classes in the generated python
I'm looking for a good way to antialias a bitmap i'm generating with actionscript3.
I have an application where I am generating many Bitmap objects. Once I create
I want to show a progressbar downloading a bitmap: public static Bitmap getBitmapFromURL(String src)
Generating moc_krvfshandler.cpp [ 2%] [ 2%] Building CXX object krusader/GUI/CMakeFiles/GUI.dir/GUI_automoc.o Building CXX object krusader/DiskUsage/CMakeFiles/DiskUsage.dir/DiskUsage_automoc.o
In my website I am generating a Bitmap dynamically and it needs to be
I am getting the error java.lang.OutOfMemoryError: bitmap size exceeds VM budget . This occurs
Generating normal columnar data in excel file is quite easy but does any one

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.