Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Animated GIF support, anybody?
Animated GIF support, anybody? [message #26531] Mon, 10 May 2010 08:13 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I guess this is a valid request:

http://www.ultimatepp.org/forum/index.php?t=msg&th=2967& amp;start=0&

Well, anybody willing to add animated GIF support to plugin/GIF? Smile

Mirek
Re: Animated GIF support, anybody? [message #26965 is a reply to message #26531] Tue, 15 June 2010 15:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
luzr wrote on Mon, 10 May 2010 08:13

I guess this is a valid request:

http://www.ultimatepp.org/forum/index.php?t=msg&th=2967& amp; amp;start=0&

Well, anybody willing to add animated GIF support to plugin/GIF? Smile

Mirek

Hello Mirek

This is very easy. The code is there.

Just tell how you want the interface for:
- loading images: How to cross through StreamRaster-Raster-GIFRaster
- showing them.



Best regards
Iñaki
Re: Animated GIF support, anybody? [message #26966 is a reply to message #26965] Tue, 15 June 2010 19:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 15 June 2010 09:33

luzr wrote on Mon, 10 May 2010 08:13

I guess this is a valid request:

http://www.ultimatepp.org/forum/index.php?t=msg&th=2967& amp; amp; amp;start=0&

Well, anybody willing to add animated GIF support to plugin/GIF? Smile

Mirek

Hello Mirek

This is very easy. The code is there.

Just tell how you want the interface for:
- loading images: How to cross through StreamRaster-Raster-GIFRaster
- showing them.




Actually, interfaces are already there for Raster:

class Raster {
....
public:
	virtual void    SeekPage(int page);
	virtual int     GetActivePage() const;
	virtual int     GetPageCount();



RasterEncoder might need one or two new virtual methods.

Mirek
Re: Animated GIF support, anybody? [message #26969 is a reply to message #26966] Tue, 15 June 2010 23:52 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
luzr wrote on Tue, 15 June 2010 19:19

koldo wrote on Tue, 15 June 2010 09:33

luzr wrote on Mon, 10 May 2010 08:13

I guess this is a valid request:

http://www.ultimatepp.org/forum/index.php?t=msg&th=2967& amp; amp; amp; amp; amp;start=0&

Well, anybody willing to add animated GIF support to plugin/GIF? Smile

Mirek

Hello Mirek

This is very easy. The code is there.

Just tell how you want the interface for:
- loading images: How to cross through StreamRaster-Raster-GIFRaster
- showing them.




Actually, interfaces are already there for Raster:

class Raster {
....
public:
	virtual void    SeekPage(int page);
	virtual int     GetActivePage() const;
	virtual int     GetPageCount();



RasterEncoder might need one or two new virtual methods.

Mirek

Hello Mirek

I imagine you say the frame rate (time between frames per every frame) or the aspect ratio Smile.

Meanwhile please think about visualization interface.


Best regards
Iñaki

[Updated on: Tue, 15 June 2010 23:59]

Report message to a moderator

Re: Animated GIF support, anybody? [message #26979 is a reply to message #26969] Wed, 16 June 2010 14:15 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Mirek

Here I enclose you the files changed.

Just for testing (do not consider it a serious player Smile ) I have used the next simple code. It shows 100 frames repeating them if the gif have less frames. Delay is considered but aspect is not.

	FileIn in(fileName);
	One<StreamRaster> raster = StreamRaster::OpenAny(in);
	int ind = 0;
	for (int i = 0; i < 100; ++i) {
		raster->SeekPage(ind);
		image = raster->GetImage();
		
		Refresh();
		Ctrl::ProcessEvents();

		int delay = raster->GetPageDelay(ind);
		if (delay <= 0)
			Sleep(100);
		else
			Sleep(delay*10);
		
		if (ind < raster->GetPageCount()-1)
			ind++;
		else
			ind = 0;				
	}


I have added two new virtual functions:

virtual int GetPageAspect(int n);
virtual int GetPageDelay(int n); 



In GIF format it is defined a delay per frame, but an aspect ratio for all frame set, so a GetAspect(void) version would be valid.

  • Attachment: GifFiles.7z
    (Size: 10.27KB, Downloaded 260 times)


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #26991 is a reply to message #26979] Fri, 18 June 2010 10:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Wonderful, thank you.

But what about Encoder? Smile

Also, maybe you could send me complete testing package so that we can add reference example... (Or you can do it yourself).

Mirek

[Updated on: Fri, 18 June 2010 10:23]

Report message to a moderator

Re: Animated GIF support, anybody? [message #26992 is a reply to message #26991] Fri, 18 June 2010 11:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
luzr wrote on Fri, 18 June 2010 10:22

Wonderful, thank you.

But what about Encoder? Smile

Also, maybe you could send me complete testing package so that we can add reference example... (Or you can do it yourself).

Mirek

Hello Mirek

Before doing the encoder I would prefer to prepare the player class Smile. I think it has higher priority.

Anyway do you want to include a Reference example for multipage decoding?. This example (as code updated before) would serve for .GIF and for :TIFF files too.


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27004 is a reply to message #26992] Sun, 20 June 2010 23:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Quoting Koldo's PM:

Quote:


- Our Gif support does not work well for all samples I have tested from here (http://www.animatedgif.net/).
I have tested bad files with previous U++ GIF support and the problems also appear, so they are not caused by last changes.

Do you know what was the source of our original GIF code to try to get an update or try to now where the problem comes?

Re: Animated GIF support, anybody? [message #27005 is a reply to message #27004] Sun, 20 June 2010 23:26 Go to previous messageGo to next message
rylek is currently offline  rylek
Messages: 79
Registered: November 2005
Member
Hi Koldo!

Mirek asked me to have a look at the malfunctioning GIF's. Can you please send me links to some GIF's from the web page you mentioned which don't work?

Thanks

Tomas
Re: Animated GIF support, anybody? [message #27006 is a reply to message #27005] Mon, 21 June 2010 00:24 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi,

I just tested the reference player with this image, which is one of the nonworking ones. I came to conclusion that the troubles come from the fact that it is optimized. (Some of the subimages have smaller size).

If I changed the layer sizes in gimp and resaved, it works almost fine, it only changes the disposal method. That could be probably fixed too.

The changed file is attached for reference...

Honza
Re: Animated GIF support, anybody? [message #27007 is a reply to message #27006] Mon, 21 June 2010 09:16 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Tomas

Some days ago I hacked your code to decode animated GIFs.

It works well for some files but there are problems with other.

I checked some of the failed files with old code and the problem appeared.

Honza (dolik.rce) has detected one source of the failure. The Gif he includes has different image size per page (subimage). I think he has got the problem as it happens the same with other failed files:

- the images seems scrambled
- however, the images colors look right
- there is at least one image right

It seems to indicate that the colors are decoded right, but some of the pages begin and end are taken wrong.

I have tried to implement this change in subimage size but results do not improve.

Could you do/fix the code or give me some info about the inner details of GIF format you used to do your code?


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27010 is a reply to message #27007] Mon, 21 June 2010 09:38 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Koldo & Tomas,

I had a quick look at the GIF format spec. The relevant part is paragraph 20. The data block described there should be loaded in GifLocalInfo::Load(). The code seems that it is already doing that.

But since the picture loaded is distorted, it seems that this information (GifLocalInfo::{x,y,width,height}) is not treated in GifProcessor::LoadSubimage(). It only checks if the values are sane. I guess it should also pad the actual image with transparent frame according to the x,y,width and height.

Sorry I don't dig into it myself, but my finals are coming tommorow Wink But expect my helping in few days, if it is not finished by then.

Honza
Re: Animated GIF support, anybody? [message #27011 is a reply to message #27010] Mon, 21 June 2010 10:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
dolik.rce wrote on Mon, 21 June 2010 09:38

Hi Koldo & Tomas,

I had a quick look at the GIF format spec. The relevant part is paragraph 20. The data block described there should be loaded in GifLocalInfo::Load(). The code seems that it is already doing that.

But since the picture loaded is distorted, it seems that this information (GifLocalInfo::{x,y,width,height}) is not treated in GifProcessor::LoadSubimage(). It only checks if the values are sane. I guess it should also pad the actual image with transparent frame according to the x,y,width and height.

Sorry I don't dig into it myself, but my finals are coming tommorow Wink But expect my helping in few days, if it is not finished by then.

Honza

Agree. Working on that now.


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27013 is a reply to message #27011] Mon, 21 June 2010 11:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Problem found and solved! Now failed Gifs are opened well Smile

The problem came from animated GIFs have different bitmaps with different sizes and locations, so lets say subimage 3 is the mix of 0, 1, 2 and 3 overlapped in their locations!!

This is an extreme sample of it Smile

index.php?t=getfile&id=2589&private=0

Thank you Honza.
  • Attachment: AG00052_.GIF
    (Size: 7.51KB, Downloaded 1131 times)


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27018 is a reply to message #27013] Mon, 21 June 2010 16:13 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
And thank you Tomáš.

You did the 95% of the job Smile.


Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27030 is a reply to message #27018] Tue, 22 June 2010 00:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Mirek

Included new code for Raster and plugin/Gif.

Virtual funcions added are:
- Rect GetPageRect(int n). Gets the subimage Rect
- int GetPageDisposal(int n). Gets the way the subimage has to be handled by the renderer

Reference/RasterMultiPage example has been uploaded covering these changes.
  • Attachment: Gif.7z
    (Size: 8.93KB, Downloaded 244 times)


Best regards
Iñaki

[Updated on: Tue, 22 June 2010 00:25]

Report message to a moderator

Re: Animated GIF support, anybody? [message #27080 is a reply to message #27030] Thu, 24 June 2010 20:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thank you.
Re: Animated GIF support, anybody? [message #27083 is a reply to message #27080] Thu, 24 June 2010 23:27 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Very good

Now last disposal method ("Restore to previous") is included in RasterMultiPage Reference demo.

And now is the time for the GIF animation player control. If you tell me the basic class methods I can do it for yourself.



Best regards
Iñaki
Re: Animated GIF support, anybody? [message #27118 is a reply to message #27083] Sat, 26 June 2010 18:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 24 June 2010 17:27

Very good

Now last disposal method ("Restore to previous") is included in RasterMultiPage Reference demo.

And now is the time for the GIF animation player control. If you tell me the basic class methods I can do it for yourself.




You mean like specialized Ctrl to display GIF animation? Or rather some generic animation player?

Mirek
Re: Animated GIF support, anybody? [message #27120 is a reply to message #27118] Sat, 26 June 2010 18:12 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
luzr wrote on Sat, 26 June 2010 18:02

koldo wrote on Thu, 24 June 2010 17:27

Very good

Now last disposal method ("Restore to previous") is included in RasterMultiPage Reference demo.

And now is the time for the GIF animation player control. If you tell me the basic class methods I can do it for yourself.




You mean like specialized Ctrl to display GIF animation? Or rather some generic animation player?

Mirek

Yes Smile

Something somebody puts in the layout designer, enter a file name or String with GIF file, and just plays the animation when the window is opened.


Best regards
Iñaki
Previous Topic: Linux anti-aliasing fonts problem
Next Topic: TheIde SVN problem in windows 7
Goto Forum:
  


Current Time: Sat Apr 20 04:52:09 CEST 2024

Total time taken to generate the page: 0.03125 seconds