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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:31:46+00:00 2026-06-09T10:31:46+00:00

I have this class that im getting the information from the animated gif: using

  • 0

I have this class that im getting the information from the animated gif:

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.IO;

public class AnimatedGif
{
    private List<AnimatedGifFrame> mImages = new List<AnimatedGifFrame>();
    public AnimatedGif(string path)
    {
        Image img = Image.FromFile(path);
        int frames = img.GetFrameCount(FrameDimension.Time);
        if (frames <= 1) throw new ArgumentException("Image not animated");
        byte[] times = img.GetPropertyItem(0x5100).Value;
        int frame = 0;
        for (; ; )
        {
            int dur = BitConverter.ToInt32(times, 4 * frame);
            mImages.Add(new AnimatedGifFrame(new Bitmap(img), dur));
            if (++frame >= frames) break;
            img.SelectActiveFrame(FrameDimension.Time, frame);
        }
        img.Dispose();
    }
    public List<AnimatedGifFrame> Images { get { return mImages; } }
}

public class AnimatedGifFrame
{
    private int mDuration;
    private Image mImage;
    internal AnimatedGifFrame(Image img, int duration)
    {
        mImage = img; mDuration = duration;
    }
    public Image Image { get { return mImage; } }
    public int Duration { get { return mDuration; } }
}

Then in Form1 in the constructor im looping over the List of images and get the duration of each of the images. So in the List in this case there are 4 images each one duration is 1.

So when im showing the animatd gif im trying to display the speed in a label.
But there are two problems:

  1. The loop in the end show me that speed is now 2 not 4.
  2. The label the result there is all the time 0 and 2/100 is not 0.

What i want to do is to show the actual speed.
Like in the program Easy gif animator 5:

If im standing on one image from the 4 i see that its speed is 0.01seconds wich is Delay 1 wich is 1/100th sec.

And if i mark all the images in the program i get speed 0.04 seconds.

Maybe i confusing between speed and duration.

I want to get the speed of the animated gif.

This is my code in Form1:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyAnimatedGifEditor
{


    public partial class Form1 : Form
    {
        int speed;
        Image myImage;
        AnimatedGif myGif;

        public Form1()
        {
            InitializeComponent();

            myImage = Image.FromFile(@"D:\fananimation.gif");
            myGif = new AnimatedGif(@"D:\fananimation.gif");
            for (int i = 0; i < myGif.Images.Count; i++)
            {

                speed = myGif.Images[i].Duration;
                speed++;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = myImage;
            label2.Text = (speed / 100).ToString();
        }
    }
}

Image from the easy gif animator after selected all images:

enter image description here

In the end i want to show on two labels one the duration of the animated gif and one the speed.

  • 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-09T10:31:48+00:00Added an answer on June 9, 2026 at 10:31 am

    There is a problem with the portion of your code where you are looping through the images of the animated gif. You probably want two separate variables here instead of just speed.

    So something like

    for (int i = 0; i < myGif.Images.Count; i++)
    {
        totalDuration += myGif.Images[i].Duration;
        count++;
    }
    

    And to solve your integer math problem, divide by 100.0 instead of 100:

    label2.Text = (totalDuration / 100.0).ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient
I have this small class called City that simply holds some information about a
I have the following ColdFusion code that is getting information from a database and
I have an application that gets information from google calendar by getting them from
I have this class that have a function to load other classes and create
I have this class that has many class members, and a lot of different
I have this c# class that calculates n choose k and then generates all
I have this class called PollFrame that extends JFrame in a file called PollFrame.java
I have class that looks like this: class A { public: class variables_map vm
I have a class that contains this class method: def self.get_event_record(row, participant) event =

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.