datadink / bumpkit Goto Github PK
View Code? Open in Web Editor NEWA .NET imaging library that extends System.Drawing functionality
License: The Unlicense
A .NET imaging library that extends System.Drawing functionality
License: The Unlicense
seems that on line 157 of GifEncoder.cs
:
var dataLength = sourceGif.ReadByte();
dataLength
is zero and the loop to write the frame never starts.
The same code works well on Windows.
The demo use a static image, create multiple frame by rotation and save a gif. But if the original Image loaded is a Gif, it seems to create a corrupted file.
See this code:
private static byte[] ToGifByteArray(Image image)
{
var frameCount = image.GetFrameCount(FrameDimension.Time);
var times = image.GetPropertyItem(0x5100).Value; // PropertyTagFrameDelay
using (var memoryStream = new MemoryStream())
{
using (var encoder = new GifEncoder(memoryStream, null, null, -1))
{
for (var idx = 0; idx < frameCount; idx++)
{
image.SelectActiveFrame(FrameDimension.Time, idx);
var dur = BitConverter.ToInt32(times, 4 * 0);
encoder.AddFrame(image, 0, 0, TimeSpan.FromSeconds(dur));
}
}
File.WriteAllBytes(@"C:\test.gif", memoryStream.ToArray());
return memoryStream.ToArray();
}
}
If I pass a Image loaded from a gif, it create a corrupted. If I comment the first two lines for the timing and the loop for the frame and pass a Image loaded from a jpeg, it create a working gif.
Can't upload GIF produced by BumKit to Imgur/Twitter.
Here is an answer from Imgur support team, the same answer from Twitter:
"Thanks for writing! I think that's a problem with the image file. It's failing to strip the metadata during upload. Could you try another image to upload in the meantime? I've created a bug report and the developers will be looking into this."
Hi,
Perhaps I've been doing this the wrong way im not sure - ive been using the same way as https://psycodedeveloper.wordpress.com/2013/04/26/saving-an-animated-gif-image-with-c-in-windows-forms/
For saving the created gif, but whenever I try to open it in gif viewer it causes it to crash?
Code:
using (var stream = new MemoryStream()) { using (var encoder = new BumpKit.GifEncoder(stream)) {
for (int i = 0; i < 50; i++)
{
graphics.CopyFromScreen(region.Left, region.Top, 0, 0, region.Size);
CURSORINFO pci;
pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
if (GetCursorInfo(out pci))
{
if (pci.flags == CURSOR_SHOWING)
{
var hdc = graphics.GetHdc();
DrawIconEx(hdc, pci.ptScreenPos.x - region.X, pci.ptScreenPos.y - region.Y, pci.hCursor, 0, 0, 0, IntPtr.Zero, DI_NORMAL);
graphics.ReleaseHdc();
}
}
encoder.AddFrame(bitmap , 0, 0, TimeSpan.FromSeconds(0)); }
stream.Position = 0; using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { stream.WriteTo(fileStream); }
}
}
Apologies for the format i wrote this on my phone
I capture the users screen and mouse movements to put together a gif (also how many images would it need to capture to create a smooth 20 second gif?)
I have a sequence of PNG images which I want to use for generating an animated gif. The library works well by stitching the png images to make a gif but looses the transparency while conversion.
The converted gif appears to be grey and white.
Any fix for this?
The Repeat property of the gif encoder class works with the values:
-1 = No repeat.
0 = Repeat forever.
n = +Iterations. (if n set to 3, the frames will be displayed 4 times)
The problem is, if i set n to 1, iterates 3 times. But not 2 times as expected!
This comment in Form1.cs, line 74:
var gifStream = new MemoryStream(); // NOTE: Disposing this stream will break this demo - I don't know why.
According to the MSDN doc for Image.FromStream(), "You must keep the stream open for the lifetime of the Image."
FYI.
^^^ as described. I have two simple PNGs with a transparency channel and the resulting GIF with 100ms delay per frame is unreadable by any program.
Is there any way to increase the quality? It's very low right now...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.