Gif in windows form

GIF Animation not working in Windows Form

I have 2 WinForms

Form2 uses Infragistics ultraTabControl. On Tab Changing im Showing Form1.

In Form1

I have a PictureBox assigned with animated GIF

In Form2

I am displaying Form1 like this.

Problem

GIF is not playing animation.

7 Answers 7

Make sure you have your image in the image property NOT THE BACKGROUND IMAGE PROPERTY. That’s the mistake I made

It is working fine for me. I have just dragged a new pictureBox on form and setting image property at Form_Load() event and showing GIF animated.

I did same as you on button click:

At my Test Form:

Note: If your picture box is disabled then it will not animate the Gif

Try to implement using this link:Animated GIF in picturebox won’t animate apprach.

Solved

My current Thread is busy to Play GIF Animation.

I tried So many ways like Application.DoEvents(); etc. But every thing can’t helped me.

The answer in the following Question, which uses Threading is a very great working idea.

Thanks for every one.

The best way to achieve it is to run the animation in an async task, but accordingly, some limitations are possible to do that on windows form using:

My splash view is displayed with a gif (loading)

e.g.: In your constructor,

It is imperative to put the Thread.Sleep(int) after starting a new one, don’t forget that every action you did on this thread needs to be invoked, for example:

Now your gif should work!

This question has already raised before. Though the approach is different but the questions concept is the same

Source project where you can use Code Project

I guess that will help you out

I had the same issue and came across different solutions by implementing which I used to face several different issues. Finally, below is what I put some pieces from different posts together which worked for me as expected.

Here is the Execution method that also carries invoking the PictureBox control:

Keep in mind, the PictureBox is invisible from Properties Window or do below:

Читайте также:  Самый легкий дистрибутив windows

If none of the previous answers work for you, another idea is to refresh the image tag or write it on the fly with jQuery.
In my case I needed to show an animated GIF when a button on the form was clicked. Previously it would show up but not animate. I just added a jQuery event when the button was clicked that added the image tag on-the-fly to a div through the parent tag’s html() function.

Worth a shot especially if you’re already using jquery on your page.

How do you show animated GIFs on a Windows Form (c#)

I have a form showing progress messages as a fairly long process runs. It’s a call to a web service so I can’t really show a percentage complete figure on a progress bar meaningfully. (I don’t particularly like the Marquee property of the progress bar)

I would like to show an animated GIF to give the process the feel of some activity (e.g. files flying from one computer to another like Windows copy process).

How do you do this?

7 Answers 7

It’s not too hard.

  1. Drop a picturebox onto your form.
  2. Add the .gif file as the image in the picturebox
  3. Show the picturebox when you are loading.

Things to take into consideration:

  • Disabling the picturebox will prevent the gif from being animated.

Animated gifs:

If you are looking for animated gifs you can generate them:

Another way of doing it:

Another way that I have found that works quite well is the async dialog control that I found on the code project

I had the same problem. Whole form (including gif) stopping to redraw itself because of long operation working in the background. Here is how i solved this.

I simply created another thread to be responsible for this operation. Thanks to this initial form continues redrawing without problems (including my gif working). ShowProgressGifDelegate and HideProgressGifDelegate are delegates in form that set visible property of pictureBox with gif to true/false.

Note that in Windows, you traditionally don’t use animated Gifs, but little AVI animations: there is a Windows native control just to display them. There are even tools to convert animated Gifs to AVI (and vice-versa).

Как вы показываете анимированные GIF-файлы в форме Windows (c #)

У меня есть форма, показывающая сообщения о проделанной работе во время довольно длительного процесса. Это вызов веб-службы, поэтому я не могу реально показать процентное значение в строке прогресса. (Мне не особенно нравится свойство Marquee индикатора выполнения)

Читайте также:  Стим не запускается после переустановки windows

Я хотел бы показать анимированный GIF-файл, чтобы дать процессу ощущение некоторой активности (например, файлы, летящие с одного компьютера на другой, например процесс копирования Windows).

Как ты это делаешь?

6 ответов

Это не так уж сложно.

  1. Поместите картинку в форму.
  2. Добавьте файл .gif в качестве изображения в поле для картинок
  3. Показывать коробку с картинками при загрузке.

Что нужно учитывать:

  • Отключение окна рисунка предотвратит анимацию изображения.

Анимированные картинки:

Если вы ищете анимированные картинки, вы можете сгенерировать их здесь

Другой способ сделать это:

Другой способ, который я нашел и который работает довольно хорошо, — это элемент управления асинхронным диалогом, который я нашел на код проекта

У меня была такая же проблема. Вся форма (включая gif) останавливается, чтобы перерисовать себя из-за длительной работы в фоновом режиме. Вот как я это решил.

Я просто создал другой поток, который будет отвечать за эту операцию. Благодаря этой первоначальной форме продолжает перерисовывать без проблем (в том числе моя работа GIF). ShowProgressGifDelegate и HideProgressGifDelegate являются делегатами в форме, которые устанавливают видимое свойство pictureBox с gif в значение true /false.

Обратите внимание, что в Windows вы традиционно не используете анимированные Gif-файлы, а небольшие AVI-анимации: для их отображения есть собственный элемент управления Windows. Есть даже инструменты для преобразования анимированных GIF-файлов в AVI (и наоборот).

Если вы поместите его в элемент управления PictureBox, он должен просто работать

Это не так, когда вы начинаете долгую операцию позади, потому что все ОСТАНАВЛИВАЕТСЯ, так как вы находитесь в том же потоке.

У меня была та же проблема, и я сталкивался с различными решениями, применяя которые я столкнулся с несколькими разными проблемами. Наконец, ниже я собрал несколько фрагментов из разных постов, что сработало для меня, как и ожидалось.

Вот метод Execution, который также вызывает вызов элемента управления PictureBox:

Имейте в виду, PictureBox невидим из окна свойств или сделайте ниже:

Can a PictureBox show animated GIF in Windows Application?

I would like to show a animated gif in .Net Winform. How to do this?

I previously used VB 6.0.

3 Answers 3

Put a PictureBox on a form and then specify a picture file with a Gif extension. Or:

Читайте также:  Запуск с скрипт windows

Programatically animate a gif Image loading frames into a PictureBox with code, here’s the Gif class:

VB.NET

C#

C# usage:

Open a Winform project drag and drop in a PictureBox , a Timer and a Button, with the GifImage.cs the class is shown above.

Developing on @JeremyThompson’s answer I would like to add a code snippet to show how you can implement the first approach, because it is a lot simpler, and does not require you to manually animate the gif, seeing that the PictureBox has a built-in feature to handle such a scenario. Just add a PictureBox to your form, and in the form constructor assign the image path to the PictureBox.ImageLocation

In my oppinion this is a much simpler solution, especially for someone who is new to .NET.

I’ve played around with this and the animation plays provided that you don’t perform another long running operation on the same thread. The moment you perform another long running operation, you’d want to do it in another thread.

The simplest way to do this, is to use the BackgroundWorker component that you can drag onto the form from your toolbox. You’d then put your long running operation code in the DoWork() event of the BackgroundWorker. The final step would be to invoke your code by calling the RunWorkerAsync() method of the BackgroundWorker instance.

Gif картинки

Вращение картинки относительно точки, без изменения картинки
Нужно сделать так ,чтобы картинка вращалась за счёт заданного угла ,без искажения public partial.

Transparent gif
нужно поставить transpanert gif (картинку и прозрачный фон в некоторых местах) в самом конструкторе.

GIF анимация в PictureBox
Есть проблемы, нужно на плеере поставить в ictureBox гифку и запуская анимацию при нажатии на.

Работа с файлами .Gif
Уважаемые форумчане, доброй ночи! Подскажите пожалуйста,как заставить проигрывать свою анимацию.

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Изменение размера .gif
Товарищи! Я крайне нуждаюсь в вашей помощи! Как можно изменить размер .gif файла с анимацией.

Отображение gif в pictureBox
В общем, на форме есть pictureBox и 2 события — MouseMove и MouseLeave. Сначала отображается просто.

Не загружает gif в pictureBox
Всех приветствую. Не загружается gif в пикчбокс, пустая при отладке. Почему так? .

Gif-анимация застывает
Есть прозрачное окно с gif-анимацией (Visual C++, WinForms). При перекрытии моего окна другим.

Оцените статью