 |
|
 |
The first frame of all exported gifs seems to have each pixel of one (and only one) color replaced with white.
This only happens with the first frame. Someone help, please, because this is driving me insane. :(
|
|
|
|
 |
|
|
 |
|
 |
Awesome Thank you Simon !
|
|
|
|
 |
|
 |
Hello,
nice work on this library. One detail though; after AnimatedGifEncoder finishes i try to delete the input files however the following exception arises: "System.IO.IOException: The process cannot access the file 'C:\img.jpg.2gf.5' because it is being used by another process."
This is the code that i have added the Example.Main().
Thread t = new Thread(delegate() { try { foreach (var filePath in imageFilePaths) { new FileInfo(filePath).Delete(); } } catch (IOException ex) {
} });
t.Start();
It catches the exception and it is the cleanest way around i could find. I would like, however, to know if is there any other way around it, like forcing the release of the images in your src code ?
Thank you
|
|
|
|
 |
|
 |
Hi gOODiDEA.NET, great work.
I've created a derived work based on Phil@ThinkEdge's amended version of this library. The main changes I've made are adding support for a single global colour table (as opposed to a local colour table for each frame) to the encoder, making use of generics in .net 2.0, and factoring out many of the building blocks of GIF files into their own separate classes with most of their attributes exposed as public properties.
I've also written two small applications which make use of this derived work, and I'd like to publish/release the lot under a free software license (ideally the GNU GPL if that's compatible with the CPOL). Would that be OK with you?
Simon.
|
|
|
|
 |
|
 |
Please do !!!! We cant wait for a new version  (if you dont want to make it public yet, would you mind to send it to me, so i can try it ?) cheers
|
|
|
|
 |
|
 |
I'd love to release it into the wild, I'm just slightly reluctant to do so without GoodIdea.Net's blessing. Having said that, I'm not sure he's ever going to read or reply to this thread, so where would I stand legally if I just went ahead and released it?
Most importantly, would I be in breach of the CPOL if I were to release my version under the GPL without waiting for permission? I've read the comparison of licenses page, and I still think the GPL is most appropriate for my needs - I just want to get my code out there and have other people using it, pointing out bugs etc, I have no interest in making money out of it.
I'm not sure whether my version will count as an improvement on the one posted here. Some may find it easier to understand and use, some may find it's a lot slower, some may find it doesn't support what they could do with the original version (I'm pretty sure I've broken some features of the animator although the ones I'm using seem to work just fine). But that's where I need you good folks to try it out, and to let me know where you find it isn't working for you. And that's why I need to resolve this issue over licensing so that I can publish with a clean conscience 
|
|
|
|
 |
|
 |
Then why dont you release it under CPOL ?
|
|
|
|
 |
|
|
 |
|
 |
how do i resize an animated gif background transparency
modified on Thursday, August 27, 2009 4:06 AM
|
|
|
|
 |
|
 |
Thank you for the open source code. Works like a champ!!!
I have run into an issue with a few of the animated gifs having a transparent background when they should NOT have a transparent background.
Can I re-enforce no transparent background during the resizing process?
My implementation of your open source code...
string _tempID = Path.GetFileNameWithoutExtension(_file);
string _path = String.Format(@"~/assets/images/temp/{0}/{1}", this.Session.SessionID, _tempID.ToString()); _path = Server.MapPath(_path); if (!System.IO.Directory.Exists(_path)) System.IO.Directory.CreateDirectory(_path);
GifDecoder _gifDecoder = new GifDecoder(); _gifDecoder.Read(_file);
for (int i = 0, count = _gifDecoder.GetFrameCount(); i < count; i++) { System.Drawing.Image frame = _gifDecoder.GetFrame(i); frame.Save(String.Format(@"{0}\{1}.png", _path, Guid.NewGuid().ToString()), ImageFormat.Png); }
AnimatedGifEncoder _encoder = new AnimatedGifEncoder(); _encoder.SetTransparent(Color.Empty);
using (FileStream imageStream = new FileStream( _path + @"\temp.gif" ,FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) { _encoder.Start(imageStream); _encoder.SetDelay(_gifDecoder.GetDelay(0)); _encoder.SetRepeat(0); string[] _imagePaths = System.IO.Directory.GetFiles(_path, "*.png");
for (int i = 0, count = _imagePaths.Length; i < count; i++) _encoder.AddFrame(this.resize(_imagePaths[i], newWidth, newHeight, _increaseImageSize));
byte[] imageContent = new Byte[imageStream.Length];
imageStream.Position = 0;
imageStream.Read(imageContent, 0, (int)imageStream.Length);
this.Response.ContentType = _contentType; this.Response.AddHeader("content-length", System.Convert.ToString(imageStream.Length));
this.Response.BinaryWrite(imageContent); }
try { foreach (string _f in System.IO.Directory.GetFiles(_path)) System.IO.File.Delete(_f);
System.IO.Directory.Delete(_path); System.IO.Directory.Delete(System.IO.Directory.GetParent(_path).ToString()); } catch (Exception _ex) { Console.Write(_ex.ToString());}
_encoder.Finish();
_encoder = null; _gifDecoder = null;
this.Response.End();
I'm listening but I only speak GEEK.
|
|
|
|
 |
|
 |
Hello friend, i tried to build animations with several pictures, but only 19 pictures could be stored. Is this problem of the library or limitation of gif animations? Please inform me. Thanks. inamullah, Pakistan.
|
|
|
|
 |
|
 |
Would any one be able to tell me the following?
before extracting a animated gif to still images and resizing it and putting it back together. I need to know how to capture every frames timeline as I need some images to stay longer that others. Then resize them greating an animated gif again.
this must happen using .net
Or if possible to resize the gif not pulling it apart..
Any help will be appreciated
|
|
|
|
 |
|
 |
Please visit http://www.codeplex.com/GifLib
sorry, I can't find entry for updating the article
|
|
|
|
 |
|
|
 |
|
 |
could you provide an English version?
while looking at your new code on codeplex, it's impossible to compile it
thanks
|
|
|
|
 |
|
 |
Sorry but yours on CodePlex is a much worse "implement"!
You claim yours better but you don't deign to provide a "three-line sample by way of documentation, and on top of everything, it doesn't work: just a waste of time.
Kudos for NGif...
|
|
|
|
 |
|
 |
看到有贴子把 GetPixels 改成
(bitmap.PixelFormat == PixelFormat.Format32bppArgb || bitmap.PixelFormat == PixelFormat.Format32bppPArgb || bitmap.PixelFormat == PixelFormat.Format32bppRgb)
这种方式。 可是生成的GIF图片,用Fireworks 等的GIF软件 导入导出(不做任何操作)的图片都会把体积减了很多。。 真搞不懂
|
|
|
|
 |
|
 |
使用中发现的一个bug
/** * Analyzes image colors and creates color map. */ protected void AnalyzePixels() { int len = pixels.Length; int nPix = len / 3; indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(pixels, len, sample); // initialize quantizer colorTab = nq.Process(); // create reduced palette // convert map from BGR to RGB // for (int i = 0; i < colorTab.Length; i += 3) // { // byte temp = colorTab[i]; // colorTab[i] = colorTab[i + 2]; // colorTab[i + 2] = temp; // usedEntry[i / 3] = false; // } // map image pixels to new palette int k = 0; //以下是我增加的。不加这三句,那么,第二帧中判断是否已经使用,就不正确。 for (int i = 0; i < usedEntry.Length; i++) { usedEntry[i] = false; } //增加结束
for (int i = 0; i < nPix; i++) { int index = nq.Map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff); usedEntry[index] = true; indexedPixels[i] = (byte) index; } pixels = null; colorDepth = 8; palSize = 7; // get closest match to transparent color if specified if (transparent != Color.Empty ) { transIndex = FindClosest(transparent); } }
|
|
|
|
 |
|
|
 |
|
 |
Using unsafe code only gives a small performance improvement. The NeuQuant quantizer is the real problem. Replacing this quantizer by for example the OctreeQuantizer (used in Paint.NET) solves the problem.
|
|
|
|
 |
|
 |
Can you be more precise ? Could you explain how to do that please ?
|
|
|
|
 |
|
 |
In the LZWEncoder remove remaining and replace NextPixel(): private int NextPixel() { if (curPixel == pixAry.Length) return EOF; curPixel++; return pixAry[curPixel - 1] & 0xff; }
|
|
|
|
 |
|
 |
Thank YOU for this FIX. It saved hours....  
|
|
|
|
 |
|
|
 |