当前位置: 首页>>代码示例>>C#>>正文


C# BizwareGL.BitmapBuffer类代码示例

本文整理汇总了C#中BizHawk.Bizware.BizwareGL.BitmapBuffer的典型用法代码示例。如果您正苦于以下问题:C# BitmapBuffer类的具体用法?C# BitmapBuffer怎么用?C# BitmapBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BitmapBuffer类属于BizHawk.Bizware.BizwareGL命名空间,在下文中一共展示了BitmapBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的BizHawk.Bizware.BizwareGL.BitmapBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。