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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:39:40+00:00 2026-05-20T06:39:40+00:00

I’ve got 30+ single bitmaps (320×240 pixels) that I would like to display one

  • 0

I’ve got 30+ single bitmaps (320×240 pixels) that I would like to display one after another in full screen on Android devices resulting in an animation. Currently I implemented the animation using an ImageView and a Timer that sets the next frame and then sends a message that will apply the next frame. The resulting frame rate is very low: < 2 fps.

The timer:

animationTimer.scheduleAtFixedRate(new TimerTask() {
    @Override
    public void run() {
        Drawable frame = getNextFrame();
            if (frame != null) {
                Message message = animationFrameHandler.obtainMessage(1, frame);
                animationFrameHandler.sendMessage(message);
            }
        }
    }, 0, (int) (1000.0d / fps));

The handler:

final Handler animationFrameHandler = new Handler() {
    @Override
    public void handleMessage(Message message) {
        setImageDrawable((Drawable) message.obj);
    }
};

Since I want to achieve frame rates up to 30 fps I have to make use of another mechanism and heard of Canvas.drawBitmapMesh() and OpenGL.

If possible I would like to avoid using OpenGL.

Thank you very sharing your experiences!

  • 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-20T06:39:41+00:00Added an answer on May 20, 2026 at 6:39 am

    My now working approach is the following:

    Before starting the animation, load every frame into a List<Bitmap>. Important: Call System.gc() if you’re getting OutOfMemoryErrors – that really helps loading more bitmaps into the memory. Then have a thread running that posts the next frame to a View instance that then update it’s canvas.

    Loading the frames and starting the animation

    // Loading the frames before starting the animation
    List<Bitmap> frames = new ArrayList<Bitmap>();
    for (int i = 0; i < 30; i++) {
        // Load next frame (e. g. from drawable or assets folder)
        frames.add(...);
        // Do garbage collection every 3rd frame; really helps loading all frames into memory
        if (i %% 3 == 0) {
            System.gc();
        }
    }
    
    // Start animation
    frameIndex = 0;
    animationThread.start();
    

    Thread that applies the next frame

    private final class AnimationThread extends Thread {
        @Override
        public void run() {
            while (!isInterrupted()) {
                // Post next frame to be displayed
                animationView.postFrame(frames.get(frameIndex));
    
                // Apply next frame (restart if last frame has reached)
                frameIndex++;
                if (frameIndex >= frames.size()) {
                    frameIndex = 0;
                }
    
                try {
                    sleep(33); // delay between frames in msec (33 msec mean 30 fps)
                } catch (InterruptedException e) {
                    break;
                }
            }
        }
    }
    

    The animation view

    class AnimationView extends View {
        Bitmap frame = null;
    
        public void postFrame(Bitmap frame) {
            Message message = frameHandler.obtainMessage(0, frame);
            frameHandler.sendMessage(message);
        }
    
        protected final Handler frameHandler = new Handler() {
            @Override
            public void handleMessage(Message message) {
                if (message.obj != null) {
                    frame = (Bitmap) message.obj;
                } else {
                    frame = null;
                }
                invalidate();
            }
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            if (frame == null) return;
            canvas.drawARGB(0, 0, 0, 0);
            canvas.drawBitmap(frame, null, null, null);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a JSP page retrieving data and when single or double quotes are
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.