mainform: excise the old gif code. it's still in svn history if you want to resurrect it. doesn't really serve much purpose now that there's a full-fledged gif writer integrated to the AV dump system
This commit is contained in:
parent
7b6492c0e2
commit
511fcf4bd0
|
@ -4888,121 +4888,6 @@ namespace BizHawk.MultiClient
|
|||
return ret;
|
||||
}
|
||||
|
||||
#region Animaged Gifs
|
||||
/// <summary>
|
||||
/// Creates Animated Gifs
|
||||
/// </summary>
|
||||
/// <param name="num_images">Total number of frames in the gif</param>
|
||||
/// <param name="frameskip">How many frames to skip per screenshot in the image.
|
||||
/// A value of 5 means that frame 1002 will be an image and 1007 will be an image in the gif
|
||||
/// A value of 1 means that frame 1001 will be an image and 1002 will be an image in the gif</param>
|
||||
/// <param name="gifSpeed">How quickly the animated gif will run. A value of 1 or -1 = normal emulator speed.
|
||||
/// A value of 2 will double the speed of the gif.
|
||||
/// Input a negative value to slow down the speed of the gif.
|
||||
/// A value of -2 will be half speed</param>
|
||||
/// <param name="reversable">Flag for making the gif loop back and forth</param>
|
||||
/// <param name="filename">location to save the file</param>
|
||||
/// <returns>false if the parameters are incorrect, true if it completes</returns>
|
||||
public bool AnimatedGif(int num_images, int frameskip, int gifSpeed, bool reversable, String filename)
|
||||
{
|
||||
if (num_images < 1 || frameskip < 1 || gifSpeed == 0) return false;//Exits if settings are bad
|
||||
#region declare/insantiate variables
|
||||
List<Image> images = new List<Image>(); //Variable for holding all images for the gif animation
|
||||
// Such a scenario could be a frameskip setting of 2 and a gifSpeed setting of 3
|
||||
// This would result in 1 of every 3 images being requested getting skipped.
|
||||
// My math might be wrong at this hour, but you get the point!
|
||||
int speedTracker = 0; // To keep track of when to add another image to the list
|
||||
bool status = PressFrameAdvance;
|
||||
PressFrameAdvance = true;
|
||||
#endregion
|
||||
|
||||
#region Get the Images for the File
|
||||
int totalFrames = (gifSpeed > 0 ? num_images : (num_images * (gifSpeed * -1)));
|
||||
images.Add(Global.Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage());
|
||||
while (images.Count < totalFrames)
|
||||
{
|
||||
Image tempImage = Global.Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage(); //Holding the image in case it doesn't end up being added to the animation
|
||||
if (gifSpeed < 0)
|
||||
for (speedTracker = 0; speedTracker > gifSpeed; speedTracker--)
|
||||
images.Add(tempImage); //If the speed of the animation is to be slowed down, then add that many copies
|
||||
//of the image to the list
|
||||
|
||||
for (int j = 0; j < frameskip; j++)
|
||||
{
|
||||
StepRunLoop_Core();
|
||||
Global.Emulator.FrameAdvance(true); //Frame advance
|
||||
//Global.RenderPanel.Render(Global.Emulator.VideoProvider);
|
||||
|
||||
if (gifSpeed > 0)
|
||||
{
|
||||
speedTracker++;//Advance the frame counter for adding to the List of Images
|
||||
if (speedTracker == Math.Max(gifSpeed, frameskip))
|
||||
{
|
||||
images.Add(tempImage);
|
||||
speedTracker = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
PressFrameAdvance = status;
|
||||
|
||||
/*
|
||||
* The following code was obtained from here:
|
||||
* http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0c4252c8-8274-449c-ad9b-e4f07a8f8cdd/
|
||||
* Modified to work with the BizHawk Project
|
||||
*/
|
||||
#region make gif file
|
||||
byte[] GifAnimation = { 33, 255, 11, 78, 69, 84, 83, 67, 65, 80, 69, 50, 46, 48, 3, 1, 0, 0, 0 };
|
||||
MemoryStream MS = new MemoryStream();
|
||||
var fi = new FileInfo(filename);
|
||||
if (fi.Directory != null && fi.Directory.Exists == false)
|
||||
fi.Directory.Create();
|
||||
BinaryWriter BW = new BinaryWriter(new FileStream(filename, FileMode.Create));
|
||||
images[0].Save(MS, ImageFormat.Gif);
|
||||
byte[] B = MS.ToArray();
|
||||
B[10] = (byte)(B[10] & 0X78); //No global color table.
|
||||
BW.Write(B, 0, 13);
|
||||
BW.Write(GifAnimation);
|
||||
WriteGifImg(B, BW);
|
||||
for (int I = 1; I < images.Count; I++)
|
||||
{
|
||||
MS.SetLength(0);
|
||||
images[I].Save(MS, ImageFormat.Gif);
|
||||
B = MS.ToArray();
|
||||
WriteGifImg(B, BW);
|
||||
}
|
||||
if (reversable)
|
||||
{
|
||||
for (int I = images.Count - 2; I >= 0; I--)//Start at (count - 2) because last image is already in place
|
||||
{
|
||||
MS.SetLength(0);
|
||||
images[I].Save(MS, ImageFormat.Gif);
|
||||
B = MS.ToArray();
|
||||
WriteGifImg(B, BW);
|
||||
}
|
||||
}
|
||||
BW.Write(B[B.Length - 1]);
|
||||
BW.Close();
|
||||
MS.Dispose();
|
||||
#endregion
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void WriteGifImg(byte[] B, BinaryWriter BW)
|
||||
{
|
||||
byte[] Delay = { 0, 0 };
|
||||
B[785] = Delay[0];
|
||||
B[786] = Delay[1];
|
||||
B[798] = (byte)(B[798] | 0X87);
|
||||
BW.Write(B, 781, 18);
|
||||
BW.Write(B, 13, 768);
|
||||
BW.Write(B, 799, B.Length - 800);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ShowConsole()
|
||||
{
|
||||
LogConsole.ShowConsole();
|
||||
|
|
Loading…
Reference in New Issue