本文整理汇总了C#中BizHawk.Bizware.BizwareGL.BitmapBuffer类的典型用法代码示例。如果您正苦于以下问题:C# BitmapBuffer类的具体用法?C# BitmapBuffer怎么用?C# BitmapBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapBuffer类属于BizHawk.Bizware.BizwareGL命名空间,在下文中一共展示了BitmapBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Get
public Texture2d Get(BitmapBuffer bb)
{
//get the current entry
Texture2d CurrentTexture = CurrentTextures[0];
//TODO - its a bit cruddy here that we dont respect the current texture HasAlpha condition (in fact, theres no such concept)
//we might need to deal with that in the future to fix some bugs.
//check if its rotten and needs recreating
if (CurrentTexture == null || CurrentTexture.IntWidth != bb.Width || CurrentTexture.IntHeight != bb.Height)
{
//needs recreating. be sure to kill the old one...
if (CurrentTexture != null)
CurrentTexture.Dispose();
//and make a new one
CurrentTexture = GL.LoadTexture(bb);
}
else
{
//its good! just load in the data
GL.LoadTextureData(CurrentTexture, bb);
}
//now shuffle the buffers
CurrentTextures[0] = CurrentTextures[1];
CurrentTextures[1] = CurrentTexture;
//deterministic state, i guess
CurrentTexture.SetFilterNearest();
return CurrentTexture;
}
开发者ID:henke37,项目名称:BizHawk,代码行数:32,代码来源:TextureFrugalizer.cs
示例2: SetPending
/// <summary>
/// sets the provided buffer as pending. takes control of the supplied buffer
/// </summary>
public void SetPending(BitmapBuffer newPending)
{
lock (this)
{
if (Pending != null) ReleasedSurfaces.Enqueue(Pending);
Pending = newPending;
}
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:11,代码来源:SwappableBitmapBufferSet.cs
示例3: AddFrame
public void AddFrame(IVideoProvider source)
{
using (var bb = new BitmapBuffer(source.BufferWidth, source.BufferHeight, source.GetVideoBuffer()))
{
string subpath = GetAndCreatePathForFrameNum(mCurrFrame);
string path = subpath + ".png";
bb.ToSysdrawingBitmap().Save(path, System.Drawing.Imaging.ImageFormat.Png);
}
}
开发者ID:henke37,项目名称:BizHawk,代码行数:9,代码来源:SynclessRecorder.cs
示例4: LoadArtInternal
Art LoadArtInternal(BitmapBuffer tex)
{
AssertIsOpen(true);
Art a = new Art(this);
ArtLooseTextureAssociation[a] = tex;
ManagedArts.Add(a);
return a;
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:10,代码来源:ArtManager.cs
示例5: GetCurrent
/// <summary>
/// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
/// </summary>
public BitmapBuffer GetCurrent()
{
lock (this)
{
if (Pending != null)
{
if (Current != null) ReleasedSurfaces.Enqueue(Current);
Current = Pending;
Pending = null;
}
}
return Current;
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:16,代码来源:SwappableBitmapBufferSet.cs
示例6: LoadTexture
public Texture2d LoadTexture(BitmapBuffer bmp)
{
var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed);
var tw = new TextureWrapper() { Texture = tex };
var ret = new Texture2d(this, tw, bmp.Width, bmp.Height);
LoadTextureData(ret, bmp);
return ret;
}
开发者ID:SaxxonPike,项目名称:BizHawk,代码行数:8,代码来源:IGL_SlimDX9.cs
示例7: LoadTextureData
public unsafe void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
{
sdi.BitmapData bmp_data = bmp.LockBits();
var tw = tex.Opaque as TextureWrapper;
var dr = tw.Texture.LockRectangle(0, LockFlags.None);
//TODO - do we need to handle odd sizes, weird pitches here?
if (bmp.Width * 4 != bmp_data.Stride)
throw new InvalidOperationException();
dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height * 4);
dr.Data.Close();
tw.Texture.UnlockRectangle(0);
bmp.UnlockBits(bmp_data);
}
开发者ID:SaxxonPike,项目名称:BizHawk,代码行数:16,代码来源:IGL_SlimDX9.cs
示例8: Trim
/// <summary>
/// copies this bitmap and trims out transparent pixels, returning the offset to the topleft pixel
/// </summary>
public BitmapBuffer Trim(out int xofs, out int yofs)
{
int minx = int.MaxValue;
int maxx = int.MinValue;
int miny = int.MaxValue;
int maxy = int.MinValue;
for (int y = 0; y < Height; y++)
for (int x = 0; x < Width; x++)
{
int pixel = GetPixel(x, y);
int a = (pixel >> 24) & 0xFF;
if (a != 0)
{
minx = Math.Min(minx, x);
maxx = Math.Max(maxx, x);
miny = Math.Min(miny, y);
maxy = Math.Max(maxy, y);
}
}
if (minx == int.MaxValue || maxx == int.MinValue || miny == int.MaxValue || minx == int.MinValue)
{
xofs = yofs = 0;
return new BitmapBuffer(0, 0);
}
int w = maxx - minx + 1;
int h = maxy - miny + 1;
BitmapBuffer bbRet = new BitmapBuffer(w, h);
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++)
{
bbRet.SetPixel(x, y, GetPixel(x + minx, y + miny));
}
xofs = minx;
yofs = miny;
return bbRet;
}
开发者ID:cas1993per,项目名称:bizhawk,代码行数:42,代码来源:BitmapBuffer.cs
示例9: LoadTexture
public Texture2d LoadTexture(BitmapBuffer bmp)
{
//definitely needed (by TextureFrugalizer at least)
var sdbmp = bmp.ToSysdrawingBitmap();
IntPtr id = GenTexture();
var tw = new TextureWrapper();
tw.SDBitmap = sdbmp;
ResourceIDs.Lookup[id.ToInt32()] = tw;
return new Texture2d(this, id, null, bmp.Width, bmp.Height);
}
开发者ID:raiscan,项目名称:BizHawk,代码行数:10,代码来源:IGL_GdiPlus.cs
示例10: UpdateSourceInternal
FilterProgram UpdateSourceInternal(JobInfo job)
{
_glManager.Activate(CR_GraphicsControl);
IVideoProvider videoProvider = job.videoProvider;
bool simulate = job.simulate;
Size chain_outsize = job.chain_outsize;
int vw = videoProvider.BufferWidth;
int vh = videoProvider.BufferHeight;
if (Global.Config.DispFixAspectRatio)
{
if (Global.Config.DispManagerAR == Config.EDispManagerAR.System)
{
vw = videoProvider.VirtualWidth;
vh = videoProvider.VirtualHeight;
}
if (Global.Config.DispManagerAR == Config.EDispManagerAR.Custom)
{
vw = Global.Config.DispCustomUserARWidth;
vh = Global.Config.DispCustomUserARHeight;
}
}
int[] videoBuffer = videoProvider.GetVideoBuffer();
TESTEROO:
int bufferWidth = videoProvider.BufferWidth;
int bufferHeight = videoProvider.BufferHeight;
bool isGlTextureId = videoBuffer.Length == 1;
//TODO - need to do some work here for GDI+ to repair gl texture ID importing
BitmapBuffer bb = null;
Texture2d videoTexture = null;
if (!simulate)
{
if (isGlTextureId)
{
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
}
else
{
//wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders)
bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer);
//now, acquire the data sent from the videoProvider into a texture
videoTexture = VideoTextureFrugalizer.Get(bb);
GL.SetTextureWrapMode(videoTexture, true);
}
//TEST (to be removed once we have an actual example of bring in a texture ID from opengl emu core):
//if (!isGlTextureId)
//{
// videoBuffer = new int[1] { videoTexture.Id.ToInt32() };
// goto TESTEROO;
//}
}
//record the size of what we received, since lua and stuff is gonna want to draw onto it
currEmuWidth = bufferWidth;
currEmuHeight = bufferHeight;
//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, job.includeOSD);
filterProgram.GuiRenderer = Renderer;
filterProgram.GL = GL;
//setup the source image filter
BizHawk.Client.EmuHawk.Filters.SourceImage fInput = filterProgram["input"] as BizHawk.Client.EmuHawk.Filters.SourceImage;
fInput.Texture = videoTexture;
//setup the final presentation filter
BizHawk.Client.EmuHawk.Filters.FinalPresentation fPresent = filterProgram["presentation"] as BizHawk.Client.EmuHawk.Filters.FinalPresentation;
fPresent.VirtualTextureSize = new Size(vw, vh);
fPresent.TextureSize = new Size(bufferWidth, bufferHeight);
fPresent.BackgroundColor = videoProvider.BackgroundColor;
fPresent.GuiRenderer = Renderer;
fPresent.GL = GL;
filterProgram.Compile("default", chain_insize, chain_outsize, !job.offscreen);
if (simulate)
{
}
else
{
CurrentFilterProgram = filterProgram;
UpdateSourceDrawingWork(job);
}
//cleanup:
if (bb != null) bb.Dispose();
return filterProgram;
}
开发者ID:Kabuto,项目名称:BizHawk,代码行数:98,代码来源:DisplayManager.cs
示例11: ResolveTexture2d
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
{
var tw = tex.Opaque as TextureWrapper;
var blow = new BitmapLoadOptions()
{
AllowWrap = false //must be an independent resource
};
var bb = new BitmapBuffer(tw.SDBitmap,blow);
return bb;
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:10,代码来源:IGL_GdiPlus.cs
示例12: LoadTexture
public Texture2d LoadTexture(BitmapBuffer bmp)
{
//definitely needed (by TextureFrugalizer at least)
var sdbmp = bmp.ToSysdrawingBitmap();
var tw = new TextureWrapper();
tw.SDBitmap = sdbmp;
return new Texture2d(this, tw, bmp.Width, bmp.Height);
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:8,代码来源:IGL_GdiPlus.cs
示例13: LoadTextureData
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
{
var tw = tex.Opaque as TextureWrapper;
bmp.ToSysdrawingBitmap(tw.SDBitmap);
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:5,代码来源:IGL_GdiPlus.cs
示例14: LoadTextureData
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
{
sdi.BitmapData bmp_data = bmp.LockBits();
d3d9.Texture dtex = tex.Opaque as d3d9.Texture;
var dr = dtex.LockRectangle(0, LockFlags.None);
//TODO - do we need to handle odd sizes, weird pitches here?
dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height);
dtex.UnlockRectangle(0);
bmp.UnlockBits(bmp_data);
}
开发者ID:cas1993per,项目名称:bizhawk,代码行数:11,代码来源:IGL_SlimDX9.cs
示例15: LoadTexture
public Texture2d LoadTexture(BitmapBuffer bmp)
{
var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed);
var ret = new Texture2d(this, IntPtr.Zero, tex, bmp.Width, bmp.Height);
LoadTextureData(ret, bmp);
return ret;
}
开发者ID:cas1993per,项目名称:bizhawk,代码行数:7,代码来源:IGL_SlimDX9.cs
示例16: ResolveTexture2d
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
{
//TODO - lazy create and cache resolving target in RT
var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory);
var tw = tex.Opaque as TextureWrapper;
dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
var dr = target.LockRectangle(0, LockFlags.ReadOnly);
if (dr.Pitch != tex.IntWidth * 4) throw new InvalidOperationException();
int[] pixels = new int[tex.IntWidth * tex.IntHeight];
dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight);
var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels);
target.UnlockRectangle(0);
target.Dispose(); //buffer churn warning
return bb;
}
开发者ID:SaxxonPike,项目名称:BizHawk,代码行数:15,代码来源:IGL_SlimDX9.cs
示例17: btnExport_Click
private void btnExport_Click(object sender, EventArgs e)
{
if(mFrameInfos.Count == 0) return;
int width, height;
using(var bmp = new Bitmap(mFrameInfos[0].pngPath))
{
width = bmp.Width;
height = bmp.Height;
}
var sfd = new SaveFileDialog();
sfd.FileName = Path.ChangeExtension(mSynclessConfigFile, ".avi");
sfd.InitialDirectory = Path.GetDirectoryName(sfd.FileName);
if (sfd.ShowDialog() == DialogResult.Cancel)
return;
using (AviWriter avw = new AviWriter())
{
avw.SetAudioParameters(44100, 2, 16); //hacky
avw.SetMovieParameters(60, 1); //hacky
avw.SetVideoParameters(width, height);
var token = avw.AcquireVideoCodecToken(this);
avw.SetVideoCodecToken(token);
avw.OpenFile(sfd.FileName);
foreach (var fi in mFrameInfos)
{
using (var bb = new BitmapBuffer(fi.pngPath, new BitmapLoadOptions()))
{
var bbvp = new BitmapBufferVideoProvider(bb);
avw.AddFrame(bbvp);
}
//offset = 44 dec
var wavBytes = File.ReadAllBytes(fi.wavPath);
var ms = new MemoryStream(wavBytes);
ms.Position = 44;
var br = new BinaryReader(ms);
List<short> sampledata = new List<short>();
while (br.BaseStream.Position != br.BaseStream.Length)
{
sampledata.Add(br.ReadInt16());
}
avw.AddSamples(sampledata.ToArray());
}
avw.CloseFile();
}
}
开发者ID:henke37,项目名称:BizHawk,代码行数:48,代码来源:SynclessRecordingTools.cs
示例18: LoadTextureData
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
{
bmp.ToSysdrawingBitmap(BitmapForTexture(tex));
}
开发者ID:raiscan,项目名称:BizHawk,代码行数:4,代码来源:IGL_GdiPlus.cs
示例19: AvFrameAdvance
private void AvFrameAdvance()
{
GlobalWin.DisplayManager.NeedsToPaint = true;
if (_currAviWriter != null)
{
//TODO ZERO - this code is pretty jacked. we'll want to frugalize buffers better for speedier dumping, and we might want to rely on the GL layer for padding
try
{
//is this the best time to handle this? or deeper inside?
if (_currAviWriterFrameList != null)
{
if (!_currAviWriterFrameList.Contains(Global.Emulator.Frame))
goto HANDLE_AUTODUMP;
}
IVideoProvider output;
IDisposable disposableOutput = null;
if (_avwriterResizew > 0 && _avwriterResizeh > 0)
{
BitmapBuffer bbin = null;
Bitmap bmpin = null;
Bitmap bmpout = null;
try
{
if (Global.Config.AVI_CaptureOSD)
{
bbin = CaptureOSD();
}
else
{
bbin = new BitmapBuffer(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight, Global.Emulator.VideoProvider().GetVideoBuffer());
}
bmpout = new Bitmap(_avwriterResizew, _avwriterResizeh, PixelFormat.Format32bppArgb);
bmpin = bbin.ToSysdrawingBitmap();
using (var g = Graphics.FromImage(bmpout))
{
if (_avwriterpad)
{
g.Clear(Color.FromArgb(Global.Emulator.VideoProvider().BackgroundColor));
g.DrawImageUnscaled(bmpin, (bmpout.Width - bmpin.Width) / 2, (bmpout.Height - bmpin.Height) / 2);
}
else
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.DrawImage(bmpin, new Rectangle(0, 0, bmpout.Width, bmpout.Height));
}
}
output = new BmpVideoProvider(bmpout);
disposableOutput = (IDisposable)output;
}
finally
{
if (bbin != null) bbin.Dispose();
if (bmpin != null) bmpin.Dispose();
}
}
else
{
if (Global.Config.AVI_CaptureOSD)
{
output = new BitmapBufferVideoProvider(CaptureOSD());
disposableOutput = (IDisposable)output;
}
else
output = Global.Emulator.VideoProvider();
}
_currAviWriter.SetFrame(Global.Emulator.Frame);
short[] samp;
int nsamp;
if (_dumpaudiosync)
{
(_currAviWriter as VideoStretcher).DumpAV(output, Global.Emulator.SyncSoundProvider, out samp, out nsamp);
}
else
{
(_currAviWriter as AudioStretcher).DumpAV(output, _aviSoundInput, out samp, out nsamp);
}
if (disposableOutput != null)
{
disposableOutput.Dispose();
}
_dumpProxy.buffer.enqueue_samples(samp, nsamp);
}
catch (Exception e)
{
MessageBox.Show("Video dumping died:\n\n" + e);
AbortAv();
}
HANDLE_AUTODUMP:
if (_autoDumpLength > 0)
{
_autoDumpLength--;
//.........这里部分代码省略.........
开发者ID:cas1993per,项目名称:bizhawk,代码行数:101,代码来源:MainForm.cs
示例20: UpdateSourceInternal
FilterProgram UpdateSourceInternal(JobInfo job)
{
//no drawing actually happens. it's important not to begin drawing on a control
if (!job.simulate)
{
GlobalWin.GLManager.Activate(CR_GraphicsControl);
}
IVideoProvider videoProvider = job.videoProvider;
bool simulate = job.simulate;
Size chain_outsize = job.chain_outsize;
//simulate = true;
int vw = videoProvider.BufferWidth;
int vh = videoProvider.BufferHeight;
if (Global.Config.DispFixAspectRatio)
{
if (Global.Config.DispManagerAR == Config.EDispManagerAR.System)
{
vw = videoProvider.VirtualWidth;
vh = videoProvider.VirtualHeight;
}
if (Global.Config.DispManagerAR == Config.EDispManagerAR.Custom)
{
vw = Global.Config.DispCustomUserARWidth;
vh = Global.Config.DispCustomUserARHeight;
}
if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio)
{
FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh);
}
}
var padding = CalculateCompleteContentPadding(true,false);
vw += padding.Horizontal;
vh += padding.Vertical;
int[] videoBuffer = videoProvider.GetVideoBuffer();
int bufferWidth = videoProvider.BufferWidth;
int bufferHeight = videoProvider.BufferHeight;
bool isGlTextureId = videoBuffer.Length == 1;
BitmapBuffer bb = null;
Texture2d videoTexture = null;
if (!simulate)
{
if (isGlTextureId)
{
//FYI: this is a million years from happening on n64, since it's all geriatric non-FBO code
//is it workable for saturn?
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
}
else
{
//wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders)
bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer);
bb.DiscardAlpha();
//now, acquire the data sent from the videoProvider into a texture
videoTexture = VideoTextureFrugalizer.Get(bb);
//lets not use this. lets define BizwareGL to make clamp by default (TBD: check opengl)
//GL.SetTextureWrapMode(videoTexture, true);
}
}
//record the size of what we received, since lua and stuff is gonna want to draw onto it
currEmuWidth = bufferWidth;
currEmuHeight = bufferHeight;
//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, job.includeOSD);
filterProgram.GuiRenderer = Renderer;
filterProgram.GL = GL;
//setup the source image filter
Filters.SourceImage fInput = filterProgram["input"] as Filters.SourceImage;
fInput.Texture = videoTexture;
//setup the final presentation filter
Filters.FinalPresentation fPresent = filterProgram["presentation"] as Filters.FinalPresentation;
fPresent.VirtualTextureSize = new Size(vw, vh);
fPresent.TextureSize = new Size(bufferWidth, bufferHeight);
fPresent.BackgroundColor = videoProvider.BackgroundColor;
fPresent.GuiRenderer = Renderer;
fPresent.Config_FixAspectRatio = Global.Config.DispFixAspectRatio;
fPresent.Config_FixScaleInteger = Global.Config.DispFixScaleInteger;
fPresent.Padding = ClientExtraPadding;
fPresent.GL = GL;
filterProgram.Compile("default", chain_insize, chain_outsize, !job.offscreen);
if (simulate)
{
//.........这里部分代码省略.........
开发者ID:zeromus,项目名称:BizHawk,代码行数:101,代码来源:DisplayManager.cs
注:本文中的BizHawk.Bizware.BizwareGL.BitmapBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论