diff --git a/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs b/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs new file mode 100644 index 0000000000..5807925db0 --- /dev/null +++ b/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Common.IOExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + /// + /// Writes a sequence of 24bpp PNG or JPG files + /// + [VideoWriter("imagesequence", "Image sequence writer", "Writes a sequence of 24bpp PNG or JPG files (default compression quality)")] + public class ImageSequenceWriter : IDisposable, IVideoWriter + { + string BaseName; + int Frame; + + public void SetVideoCodecToken(IDisposable token) + { + } + + public void SetDefaultVideoCodecToken() + { + } + + + public void OpenFile(string baseName) + { + BaseName = baseName; + } + + public void CloseFile() + { + } + + public void SetFrame(int frame) + { + //eh? this gets ditched somehow + } + + public void AddFrame(IVideoProvider source) + { + string ext = Path.GetExtension(BaseName); + string name = Path.GetFileNameWithoutExtension(BaseName) + "_" + Frame.ToString(); + name += ext; + name = Path.Combine(Path.GetDirectoryName(BaseName), name); + BizHawk.Bizware.BizwareGL.BitmapBuffer bb = new Bizware.BizwareGL.BitmapBuffer(source.BufferWidth, source.BufferHeight, source.GetVideoBuffer()); + using (var bmp = bb.ToSysdrawingBitmap()) + { + if (ext.ToUpper() == ".PNG") + bmp.Save(name, System.Drawing.Imaging.ImageFormat.Png); + else if (ext.ToUpper() == ".JPG") + bmp.Save(name, System.Drawing.Imaging.ImageFormat.Jpeg); + } + Frame++; + } + + public void AddSamples(short[] samples) + { + } + + class CodecToken : IDisposable + { + public void Dispose() { } + } + + public IDisposable AcquireVideoCodecToken(System.Windows.Forms.IWin32Window hwnd) + { + return new CodecToken(); + } + + public void SetMovieParameters(int fpsnum, int fpsden) + { + } + + public void SetVideoParameters(int width, int height) + { + } + + public void SetAudioParameters(int sampleRate, int channels, int bits) + { + } + + public void SetMetaData(string gameName, string authors, ulong lengthMS, ulong rerecords) + { + } + + public string DesiredExtension() + { + return "png"; + } + + public void Dispose() + { + } + } +} diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index e6509610fd..efc0e5026d 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -160,6 +160,7 @@ + Form