add ctrl+shift+c to copy current client area as a screenshot (as opposed to the ctrl+c raw copy) so you can get scaling and filters too

This commit is contained in:
zeromus 2014-07-22 00:04:28 +00:00
parent ae381fc986
commit f46973119b
4 changed files with 2927 additions and 2930 deletions

View File

@ -129,7 +129,7 @@ namespace BizHawk.Client.EmuHawk
}
}
FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize)
FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize, bool includeOSD)
{
//select user special FX shader chain
Dictionary<string, object> selectedChainProperties = new Dictionary<string, object>();
@ -150,6 +150,8 @@ namespace BizHawk.Client.EmuHawk
Filters.OSD fOSD = new Filters.OSD();
fOSD.RenderCallback = () =>
{
if (!includeOSD)
return;
var size = fOSD.FindInput().SurfaceFormat.Size;
Renderer.Begin(size.Width, size.Height);
MyBlitter myBlitter = new MyBlitter(this);
@ -195,7 +197,10 @@ namespace BizHawk.Client.EmuHawk
AppendLuaLayer(chain, "native");
//and OSD goes on top of that
chain.AddFilter(fOSD, "osd");
//TODO - things break if this isnt present (the final presentation filter gets messed up)
//so, always include it (we'll handle this flag in the callback to do no rendering)
//if (includeOSD)
chain.AddFilter(fOSD, "osd");
return chain;
}
@ -256,19 +261,21 @@ namespace BizHawk.Client.EmuHawk
{
videoProvider = videoProvider,
simulate = false,
chain_outsize = GraphicsControl.Size
chain_outsize = GraphicsControl.Size,
includeOSD = true
};
UpdateSourceInternal(job);
}
public BitmapBuffer RenderOffscreen(IVideoProvider videoProvider)
public BitmapBuffer RenderOffscreen(IVideoProvider videoProvider, bool includeOSD)
{
var job = new JobInfo
{
videoProvider = videoProvider,
simulate = false,
chain_outsize = GraphicsControl.Size,
offscreen = true
offscreen = true,
includeOSD = includeOSD
};
UpdateSourceInternal(job);
return job.offscreenBB;
@ -391,7 +398,7 @@ namespace BizHawk.Client.EmuHawk
{
videoProvider = fvp,
simulate = true,
chain_outsize = chain_outsize
chain_outsize = chain_outsize,
};
var filterProgram = UpdateSourceInternal(job);
@ -408,6 +415,7 @@ namespace BizHawk.Client.EmuHawk
public Size chain_outsize;
public bool offscreen;
public BitmapBuffer offscreenBB;
public bool includeOSD;
}
FilterProgram UpdateSourceInternal(JobInfo job)
@ -468,7 +476,7 @@ TESTEROO:
//build the default filter chain and set it up with services filters will need
Size chain_insize = new Size(bufferWidth, bufferHeight);
var filterProgram = BuildDefaultChain(chain_insize, chain_outsize);
var filterProgram = BuildDefaultChain(chain_insize, chain_outsize, job.includeOSD);
filterProgram.GuiRenderer = Renderer;
filterProgram.GL = GL;

File diff suppressed because it is too large Load Diff

View File

@ -575,6 +575,18 @@ namespace BizHawk.Client.EmuHawk
TakeScreenshotToClipboard();
}
private void ScreenshotClientClipboardMenuItem_Click(object sender, EventArgs e)
{
using (var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider, Global.Config.Screenshot_CaptureOSD))
{
bb.Normalize(true);
using (var img = bb.ToSysdrawingBitmap())
Clipboard.SetImage(img);
}
GlobalWin.OSD.AddMessage("Screenshot (client) saved to clipboard.");
}
private void ScreenshotCaptureOSDMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Screenshot_CaptureOSD ^= true;

View File

@ -816,7 +816,7 @@ namespace BizHawk.Client.EmuHawk
Clipboard.SetImage(img);
}
GlobalWin.OSD.AddMessage("Screenshot saved to clipboard.");
GlobalWin.OSD.AddMessage("Screenshot (raw) saved to clipboard.");
}
public void TakeScreenshot()
@ -1600,44 +1600,7 @@ namespace BizHawk.Client.EmuHawk
private static unsafe BitmapBuffer MakeScreenshotImage()
{
//var video = Global.Emulator.VideoProvider;
//var image = new Bitmap(video.BufferWidth, video.BufferHeight, PixelFormat.Format32bppArgb);
return new BitmapBuffer(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight, Global.Emulator.VideoProvider.GetVideoBuffer());
//this is all rotten.
//among other things, cores are required to set 0xFF000000 themselves
// TODO - replace with BitmapBuffer
//var framebuf = video.GetVideoBuffer();
//var bmpdata = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
//int* ptr = (int*)bmpdata.Scan0.ToPointer();
//int stride = bmpdata.Stride / 4;
//for (int y = 0; y < video.BufferHeight; y++)
//{
// for (int x = 0; x < video.BufferWidth; x++)
// {
// int col = framebuf[(y * video.BufferWidth) + x];
// if (Global.Emulator is TI83)
// {
// if (col == 0)
// {
// col = Color.Black.ToArgb();
// }
// else
// {
// col = Color.White.ToArgb();
// }
// }
// // make opaque
// col |= unchecked((int)0xff000000);
// ptr[(y * stride) + x] = col;
// }
//}
//image.UnlockBits(bmpdata);
//return image;
}
private void SaveStateAs()
@ -2044,7 +2007,7 @@ namespace BizHawk.Client.EmuHawk
private BitmapBuffer CaptureOSD()
{
var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider);
var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider,true);
bb.Normalize(true);
return bb;
}
@ -3385,5 +3348,7 @@ namespace BizHawk.Client.EmuHawk
{
_master = null;
}
}
}