Screenshots on tasproj branches

This commit is contained in:
nattthebear 2015-07-21 19:17:29 -04:00
parent 6e1cde2793
commit 862f82b1b2
6 changed files with 86 additions and 88 deletions

View File

@ -1,56 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.EmuHawk
{
public class BitmapBufferVideoProvider : IVideoProvider, IDisposable
{
BitmapBuffer bb;
public BitmapBufferVideoProvider(BitmapBuffer bb)
{
this.bb = bb;
}
public void Dispose()
{
if (bb != null) bb.Dispose();
bb = null;
}
public int[] GetVideoBuffer()
{
return bb.Pixels;
}
public int VirtualWidth
{
get { return bb.Width; }
}
public int VirtualHeight
{
get { return bb.Height; }
}
public int BufferWidth
{
get { return bb.Width; }
}
public int BufferHeight
{
get { return bb.Height; }
}
public int BackgroundColor
{
get { return 0; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.Common
{
public class BitmapBufferVideoProvider : IVideoProvider, IDisposable
{
BitmapBuffer bb;
public BitmapBufferVideoProvider(BitmapBuffer bb)
{
this.bb = bb;
}
public void Dispose()
{
if (bb != null) bb.Dispose();
bb = null;
}
public int[] GetVideoBuffer()
{
return bb.Pixels;
}
public int VirtualWidth
{
get { return bb.Width; }
}
public int VirtualHeight
{
get { return bb.Height; }
}
public int BufferWidth
{
get { return bb.Width; }
}
public int BufferHeight
{
get { return bb.Height; }
}
public int BackgroundColor
{
get { return 0; }
}
}
}

View File

@ -103,6 +103,7 @@
<Compile Include="7z\SevenZipSfx.cs" />
<Compile Include="7z\StreamWrappers.cs" />
<Compile Include="BinarySaveStates.cs" />
<Compile Include="BitmapBufferVideoProvider.cs" />
<Compile Include="config\Binding.cs" />
<Compile Include="config\Config.cs" />
<Compile Include="config\ConfigService.cs" />

View File

@ -143,6 +143,25 @@ namespace BizHawk.Client.Common
}
}
public unsafe static void Copy(IVideoProvider src, IVideoProvider dst)
{
fixed (int* srcp = src.GetVideoBuffer(), dstp = dst.GetVideoBuffer())
{
Blit(new BMP
{
Data = srcp,
Width = src.BufferWidth,
Height = src.BufferHeight
},
new BMP
{
Data = dstp,
Width = src.BufferWidth,
Height = src.BufferHeight
});
}
}
public unsafe static bool Load(IVideoProvider v, Stream s)
{
var bf = BITMAPFILEHEADER.FromStream(s);

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.Common
{
@ -11,7 +12,7 @@ namespace BizHawk.Client.Common
public int Frame { get; set; }
public byte[] CoreData { get; set; }
public List<string> InputLog { get; set; }
public int[] OSDFrameBuffer { get; set; }
public BitmapBuffer OSDFrameBuffer { get; set; }
public TasLagLog LagLog { get; set; }
}
@ -42,15 +43,8 @@ namespace BizHawk.Client.Common
});
bs.PutLump(nframebuffer, delegate(Stream s)
{
// todo: do we want to do something more clever here?
byte[] buff = new byte[2048];
var src = b.OSDFrameBuffer;
for (int i = 0; i < src.Length; i += 512)
{
int n = Math.Min(512, src.Length - i);
Buffer.BlockCopy(src, i * 4, buff, 0, n * 4);
s.Write(buff, 0, n * 4);
}
var vp = new BitmapBufferVideoProvider(b.OSDFrameBuffer);
QuickBmpFile.Save(vp, s, 160, 120); // todo: choose size more smarterly
});
bs.PutLump(nlaglog, delegate(BinaryWriter bw)
{
@ -103,15 +97,9 @@ namespace BizHawk.Client.Common
bl.GetLump(nframebuffer, true, delegate(Stream s, long length)
{
int[] dst = new int[length / 4];
byte[] buff = new byte[2048];
for (int i = 0; i < dst.Length; i++)
{
int n = Math.Min(512, dst.Length - i);
s.Read(buff, 0, n * 4);
Buffer.BlockCopy(buff, 0, dst, i * 4, n * 4);
}
b.OSDFrameBuffer = dst;
b.OSDFrameBuffer = new BitmapBuffer(160, 120); // todo: choose size more smarterly
var vp = new BitmapBufferVideoProvider(b.OSDFrameBuffer);
QuickBmpFile.Load(vp, s);
});
bl.GetLump(nlaglog, true, delegate(BinaryReader br)

View File

@ -131,7 +131,6 @@
</Compile>
<Compile Include="AVOut\AviWriter.cs" />
<Compile Include="AVOut\AVSync.cs" />
<Compile Include="AVOut\BitmapBufferVideoProvder.cs" />
<Compile Include="AVOut\BmpVideoProvder.cs" />
<Compile Include="AVOut\FFmpegWriter.cs" />
<Compile Include="AVOut\FFmpegWriterForm.cs">

View File

@ -81,8 +81,8 @@ namespace BizHawk.Client.EmuHawk
Frame = Global.Emulator.Frame,
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()),
InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
//OSDFrameBuffer = GlobalWin.MainForm.CurrentFrameBuffer(captureOSD: true),
OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()),
OSDFrameBuffer = GlobalWin.MainForm.CaptureOSD(),
//OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()),
LagLog = Tastudio.CurrentTasMovie.TasLagLog.Clone()
};
@ -122,15 +122,6 @@ namespace BizHawk.Client.EmuHawk
}
}
private void Temp(int[] framebuffer)
{
var buff = Global.Emulator.VideoProvider().GetVideoBuffer();
for (int i = 0; i < buff.Length; i++)
{
buff[i] = framebuffer[i];
}
}
private void LoadBranch(TasBranch branch)
{
Tastudio.CurrentTasMovie.LoadBranch(branch);
@ -138,7 +129,7 @@ namespace BizHawk.Client.EmuHawk
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
Tastudio.LoadState(stateInfo);
//SavestateManager.PopulateFramebuffer(branch.OSDFrameBuffer);
Temp(branch.OSDFrameBuffer);
//Temp(branch.OSDFrameBuffer);
GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.PauseOnFrame = null;
Tastudio.RefreshDialog();