possibly fast light bitmap saver with resize, TODO hook up to something
This commit is contained in:
parent
45b2fcb8af
commit
b3b37c46c3
|
@ -150,16 +150,16 @@
|
|||
<Compile Include="movie\bk2\Bk2MnemonicConstants.cs" />
|
||||
<Compile Include="movie\bk2\Bk2Movie.cs" />
|
||||
<Compile Include="movie\bk2\Bk2Movie.HeaderApi.cs">
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bk2\Bk2Movie.InputLog.cs">
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bk2\Bk2Movie.IO.cs">
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bk2\Bk2Movie.ModeApi.cs">
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
<DependentUpon>Bk2Movie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bkm\BkmControllerAdapter.cs" />
|
||||
<Compile Include="movie\bkm\BkmHeader.cs" />
|
||||
|
@ -167,16 +167,16 @@
|
|||
<Compile Include="movie\bkm\BkmMnemonicConstants.cs" />
|
||||
<Compile Include="movie\bkm\BkmMovie.cs" />
|
||||
<Compile Include="movie\bkm\BkmMovie.HeaderApi.cs">
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bkm\BkmMovie.InputLog.cs">
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bkm\BkmMovie.IO.cs">
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\bkm\BkmMovie.ModeApi.cs">
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
<DependentUpon>BkmMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\conversions\MovieConversionExtensions.cs" />
|
||||
<Compile Include="movie\HeaderKeys.cs" />
|
||||
|
@ -192,10 +192,10 @@
|
|||
<Compile Include="movie\SubtitleList.cs" />
|
||||
<Compile Include="movie\tasproj\TasLagLog.cs" />
|
||||
<Compile Include="movie\tasproj\TasMovie.Editing.cs">
|
||||
<DependentUpon>TasMovie.cs</DependentUpon>
|
||||
<DependentUpon>TasMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\tasproj\TasMovie.IO.cs">
|
||||
<DependentUpon>TasMovie.cs</DependentUpon>
|
||||
<DependentUpon>TasMovie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\tasproj\TasMovie.cs" />
|
||||
<Compile Include="movie\tasproj\TasMovieMarker.cs" />
|
||||
|
@ -205,6 +205,7 @@
|
|||
<Compile Include="NESGameGenieEncoderDecoder.cs" />
|
||||
<Compile Include="PathManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="QuickBmpFile.cs" />
|
||||
<Compile Include="RecentFiles.cs" />
|
||||
<Compile Include="rewind\Rewinder.cs" />
|
||||
<Compile Include="rewind\RewindThreader.cs" />
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BizHawk.Emulation.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class QuickBmpFile
|
||||
{
|
||||
#region structs
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
class BITMAPFILEHEADER
|
||||
{
|
||||
public ushort bfType;
|
||||
public uint bfSize;
|
||||
public ushort bfReserved1;
|
||||
public ushort bfReserved2;
|
||||
public uint bfOffBits;
|
||||
|
||||
public BITMAPFILEHEADER()
|
||||
{
|
||||
bfSize = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class BITMAPINFOHEADER
|
||||
{
|
||||
public uint biSize;
|
||||
public int biWidth;
|
||||
public int biHeight;
|
||||
public ushort biPlanes;
|
||||
public ushort biBitCount;
|
||||
public BitmapCompressionMode biCompression;
|
||||
public uint biSizeImage;
|
||||
public int biXPelsPerMeter;
|
||||
public int biYPelsPerMeter;
|
||||
public uint biClrUsed;
|
||||
public uint biClrImportant;
|
||||
|
||||
public BITMAPINFOHEADER()
|
||||
{
|
||||
biSize = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum BitmapCompressionMode : uint
|
||||
{
|
||||
BI_RGB = 0,
|
||||
BI_RLE8 = 1,
|
||||
BI_RLE4 = 2,
|
||||
BI_BITFIELDS = 3,
|
||||
BI_JPEG = 4,
|
||||
BI_PNG = 5
|
||||
}
|
||||
#endregion
|
||||
|
||||
private unsafe static byte[] GetBytes(object o)
|
||||
{
|
||||
byte[] ret = new byte[Marshal.SizeOf(o)];
|
||||
fixed (byte* p = ret)
|
||||
{
|
||||
Marshal.StructureToPtr(o, (IntPtr)p, false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public unsafe static void Save(IVideoProvider v, Stream s, int w, int h)
|
||||
{
|
||||
var bf = new BITMAPFILEHEADER();
|
||||
var bi = new BITMAPINFOHEADER();
|
||||
bf.bfType = 0x4d42;
|
||||
bf.bfOffBits = bf.bfSize + bi.biSize;
|
||||
|
||||
bi.biPlanes = 1;
|
||||
bi.biBitCount = 32; // xrgb
|
||||
bi.biCompression = BitmapCompressionMode.BI_RGB;
|
||||
bi.biSizeImage = (uint)(w * h * 4);
|
||||
bi.biWidth = w;
|
||||
bi.biHeight = h;
|
||||
|
||||
byte[] bfb = GetBytes(bf);
|
||||
byte[] bib = GetBytes(bi);
|
||||
|
||||
s.Write(bfb, 0, bfb.Length);
|
||||
s.Write(bib, 0, bib.Length);
|
||||
|
||||
int[] src = v.GetVideoBuffer();
|
||||
byte[] dst = new byte[4 * w * h];
|
||||
|
||||
fixed (int* srcp = src)
|
||||
fixed (byte* dstp = dst)
|
||||
{
|
||||
int in_w = v.BufferWidth;
|
||||
int in_h = v.BufferHeight;
|
||||
|
||||
int* sp = srcp;
|
||||
int* dp = (int*)dstp;
|
||||
|
||||
// vflip along the way
|
||||
for (int j = h - 1; j >= 0; j--)
|
||||
{
|
||||
sp = srcp + in_w * (j * in_h / h);
|
||||
for (int i = 0; i < w; i++)
|
||||
{
|
||||
dp[i] = sp[i * in_w / w];
|
||||
}
|
||||
dp += w;
|
||||
}
|
||||
}
|
||||
|
||||
s.Write(dst, 0, dst.Length);
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -895,12 +895,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
using (var bb = Global.Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage())
|
||||
{
|
||||
using(var img = bb.ToSysdrawingBitmap())
|
||||
using (var img = bb.ToSysdrawingBitmap())
|
||||
img.Save(fi.FullName, ImageFormat.Png);
|
||||
}
|
||||
|
||||
/*
|
||||
using (var fs = new FileStream(path + "_test.bmp", FileMode.OpenOrCreate, FileAccess.Write))
|
||||
QuickBmpFile.Save(Global.Emulator.VideoProvider(), fs, r.Next(50, 500), r.Next(50, 500));
|
||||
*/
|
||||
GlobalWin.OSD.AddMessage(fi.Name + " saved.");
|
||||
}
|
||||
//static Random r = new Random();
|
||||
|
||||
public void FrameBufferResized()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue