• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Surface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Surface类属于命名空间,在下文中一共展示了Surface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

 public void Draw(Surface surface, int color, int step, Point location)
 {
     foreach (Letter letter in letters) {
         letter.Draw(surface, color, location);
         location.X += step;
     }
 }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:7,代码来源:Word.cs


示例2: RenderGlyph

        private static unsafe bool RenderGlyph(FontFace typeface, char c, float pixelSize, out Surface surface)
        {
            bool result = false;

            Glyph glyph = typeface.GetGlyph(c, pixelSize);
            if (glyph != null && glyph.RenderWidth > 0 && glyph.RenderHeight > 0)
            {
                surface = new Surface
                {
                    Bits = Marshal.AllocHGlobal(glyph.RenderWidth * glyph.RenderHeight),
                    Width = glyph.RenderWidth,
                    Height = glyph.RenderHeight,
                    Pitch = glyph.RenderWidth
                };

                var stuff = (byte*)surface.Bits;
                for (int i = 0; i < surface.Width * surface.Height; i++)
                    *stuff++ = 0;

                glyph.RenderTo(surface);

                result = true;
            }
            else
            {
                surface = new Surface();
            }

            return result;
        }
开发者ID:bitzhuwei,项目名称:SharpFont,代码行数:30,代码来源:Program.cs


示例3: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a sound file.
            var sSound = dArguments.GetValueOrDefault("file", "");
            if (sSound == null || sSound == "")
            {
                Log.Write("Cannot play sound.  Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Attempt to play it.
            try
            {
                SoundPlayer pSound = new SoundPlayer(sSound);
                pSound.Play();
                return true;
            }
            
            // Log warnings.
            catch (Exception e)
            {
                Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:32,代码来源:PlaySound.cs


示例4: MafiaVideo

        public MafiaVideo(Form form, bool fullscreen)
        {
            this.form = form;
            this.fullscreen = fullscreen;

            if (fullscreen)
            {
                form.FormBorderStyle = FormBorderStyle.None;
            }
            else
            {
                form.FormBorderStyle = FormBorderStyle.Sizable;
            }

            try
            {
                device = new Device(0, DeviceType.Hardware, form, CreateFlags.HardwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
            }
            catch (InvalidCallException)
            {
                try
                {
                    device = new Device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                }
                catch (InvalidCallException)
                {
                    try
                    {
                        device = new Device(0, DeviceType.Software, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                    }
                    catch (InvalidCallException)
                    {
                        throw new Exception("Direct3Dデバイスの生成に失敗しました。");
                    }
                }
            }
            deviceLost = new EventHandler(OnDeviceLost);
            deviceReset = new EventHandler(OnDeviceReset);
            deviceResizing = new CancelEventHandler(OnDeviceResizing);
            device.DeviceLost += deviceLost;
            device.DeviceReset += deviceReset;
            device.DeviceResizing += deviceResizing;
            device.Clear(ClearFlags.Target, Color.FromArgb(212, 208, 200), 0.0f, 0);

            sprite = new Sprite(device);

            backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
            offScreenImage = new Texture(device, Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT, 1, Usage.RenderTarget, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default);
            offScreenSurface = offScreenImage.GetSurfaceLevel(0);

            texture = MafiaLoader.DefaultLoader.GetTexture(device, "mafia.bmp");

            if (fullscreen)
            {
                Cursor.Hide();
            }

            // form.ClientSize = new Size(Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT);
            form.ClientSize = new Size(Mafia.SCREEN_WIDTH * 2, Mafia.SCREEN_HEIGHT * 2);
        }
开发者ID:sinshu,项目名称:mafia,代码行数:60,代码来源:MafiaVideo.cs


示例5: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));
            if (pTargetSurface == null)
            {
                Log.Write("Cannot swap display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot swap display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // If the target surface has a display, get a reference and remove it.
            Display pOtherView = pTargetSurface.ActiveDisplay;
            if (pOtherView != null)
                Authority.RemoveDisplay(pOtherView);

            // Remove this display from this surface and put it on the target surface.
            Authority.RemoveDisplay(pDisplay);
            Authority.ShowDisplay(pDisplay, pTargetSurface);

            // Now put the other display on the original surface.
            if (pOtherView != null)
                Authority.ShowDisplay(pOtherView, pSurface);

            // Boom.
            return true;
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:40,代码来源:SwapDisplay.cs


示例6: DrawFast

		public override void DrawFast(Surface target,int x, int y,int width,int height)
		{
			if(!dying)
				images.DrawFast(target,x,y,width,height,(Direction)direction);
			else if(!moving)
				images.Death[dieFrame].DrawFast(target,x,y,width,height);
		}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:7,代码来源:Type2Unit.cs


示例7: SaveSurface

        static unsafe void SaveSurface(Surface surface, string fileName)
        {
            if (surface.Width > 0 && surface.Height > 0)
            {
                var bitmap = new Bitmap(surface.Width, surface.Height, PixelFormat.Format24bppRgb);
                var bitmapData = bitmap.LockBits(new Rectangle(0, 0, surface.Width, surface.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
                for (int y = 0; y < surface.Height; y++)
                {
                    var dest = (byte*)bitmapData.Scan0 + y * bitmapData.Stride;
                    var src = (byte*)surface.Bits + y * surface.Pitch;

                    for (int x = 0; x < surface.Width; x++)
                    {
                        var b = *src++;
                        *dest++ = b;
                        *dest++ = b;
                        *dest++ = b;
                    }
                }

                bitmap.UnlockBits(bitmapData);
                bitmap.Save(fileName);
                bitmap.Dispose();
                Marshal.FreeHGlobal(surface.Bits);
            }
        }
开发者ID:bitzhuwei,项目名称:SharpFont,代码行数:26,代码来源:Program.cs


示例8: Direct2DRenderTarget

 public Direct2DRenderTarget(DeviceContext10_1 deviceContext10, Surface surface, Format format = Format.B8G8R8A8_UNorm)
 {
     m_deviceContext10 = deviceContext10;
     m_surface = surface;
     m_format = format;
     InitializeResources(surface);
 }
开发者ID:treytomes,项目名称:DirectCanvas,代码行数:7,代码来源:Direct2DRenderTarget.cs


示例9: Doom3Map

        public Doom3Map(Doom3MapData map)
        {
            Surfaces=new List<Surface>();
            int verts = 0;
            int indices = 0;
            foreach(Doom3MapData.Model m in map.Models)
            {
                foreach(Doom3MapData.Surface s in m.Surfaces)
                {
                    VertexBuffer vb = Root.Instance.UserInterface.Renderer.CreateStaticVertexBuffer(
                        s.Vertices,
                        s.Vertices.Length*4*(3+2+3)
                        );
                    vb.Format = VertexFormat.VF_P3T2N3;

                    IndexBuffer ib = new IndexBuffer();
                    ib.buffer = new int[s.Indices.Length];
                    for (int i = 0; i < ib.buffer.Length; ++i)
                        ib.buffer[i] = s.Indices[i];

                    Surface s2 = new Surface();
                    s2.Ibuffer = ib;
                    s2.Vbuffer = vb;
                    verts += s.Vertices.Length;
                    indices += s.Indices.Length;
                    Texture t=null;
                    try
                    {
                        t = Root.Instance.ResourceManager.LoadTexture(s.Name + ".tga");
                    }
                    catch (Exception)
                    {
                        try
                        {
                            t = Root.Instance.ResourceManager.LoadTexture(s.Name + "_add.tga");
                        }
                        catch (Exception)
                        {
                            try
                            {
                                t = Root.Instance.ResourceManager.LoadTexture(s.Name + "_d.tga");
                            }
                            catch (Exception )
                            {
                                System.Console.WriteLine("warning: cant load "+s.Name);
                            }
                        }
                    }
                    s2.Material=Material.CreateSimpleMaterial(t);
                    //s2.Material.Additive = true;
                    Surfaces.Add(s2);
                }
            }
            System.Console.WriteLine("surfaces: "+Surfaces.Count.ToString());
            System.Console.WriteLine("verts: " + verts.ToString());
            System.Console.WriteLine("indices: " + indices.ToString());

            GC.Collect();
            BBox = new BoundingBox(map.BBoxMin, map.BBoxMax);
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:60,代码来源:Doom3Map.cs


示例10: AttemptRecovery

        public static void AttemptRecovery()
        {
            try
            {
                Sprite.End();
            }
            catch
            {
            }

            try
            {
                Device.EndScene();
            }
            catch
            {
            }
            try
            {
                MainSurface = Device.GetBackBuffer(0, 0, BackBufferType.Mono);
                CurrentSurface = MainSurface;
                Device.SetRenderTarget(0, MainSurface);
            }
            catch
            {
            }
        }
开发者ID:Ilmarinen946,项目名称:mir2,代码行数:27,代码来源:DXManager.cs


示例11: PixelDataProvider

        public PixelDataProvider(int width, int height, int numChannels, Device device, Usage usage)
            : base()
        {
            Format pf = Format.X8R8G8B8;
            switch (numChannels)
            {
                case 1:
                    pf = Format.A8;
                    break;
                case 3:
                    pf = Format.R8G8B8;
                    break;
                case 4:
                    pf = Format.X8R8G8B8;
                    break;
                case 8:
                    pf = Format.A16B16G16R16;
                    break;
            }
            //TODO: how to find out which Formats are supported??
            //device.DeviceCaps.TextureCaps
            if (pf == Format.R8G8B8)
                pf = Format.X8R8G8B8;

            //RenderToSurface sf = new RenderToSurface(device, width, height, pf, false, null);
            //this._tx = new Texture(device, width, height, 1, Usage.RenderTarget, pf, Pool.Default); // Pool.Managed doesn't work with Usage.RenderTarget
            Pool pool = Pool.Managed;
            if (usage == Usage.RenderTarget)
                pool = Pool.Default;

            this._tx = new Texture(device, width, height, 1, usage, pf, pool);
            //this._sd = this._tx.GetLevelDescription(0);
            this._surf = this._tx.GetSurfaceLevel(0); //AOAO
            this._sd = this._surf.Description;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:35,代码来源:PixelDataProvider.cs


示例12: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a function to return the results too.
            if (!dArguments.HasProperty("callback")) throw new Exception("Missing 'callback' argument.");

            // Return a list of surface names.
            JSValue[] lSurfaces = (from pSurf in Authority.Surfaces select new JSValue(pSurf.Identifier)).ToArray();

            // If that function is a string.
            var jsValue = dArguments["callback"];
            if (jsValue.IsString)
            {
                pDisplay.AsyncCallGlobalFunction(jsValue.ToString(), lSurfaces);
                return true;
            }

            /*
            // If it is a function.
            else if (jsValue.IsObject)
            {
                ((JSObject)jsValue).Invoke("call", lSurfaces);
                return true;
            }
            */

            // Throw the error.
            throw new Exception("Unknown type specified in 'callback' argument.  Expected string.");
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:35,代码来源:SurfaceList.cs


示例13: CreateSurface

        protected override Surface CreateSurface()
        {
            if (calc_width) {
                Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, -1, -1,
                                    Sensitive ? 4 : 24);
                Width = (ushort)textSurf.Width;
                Height = (ushort)textSurf.Height;

                return textSurf;
            }
            else {
                /* this is wrong */
                Surface surf = new Surface (Width, Height);

                Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, Width, Height,
                                    Sensitive ? 4 : 24);

                int x = 0;
                if (Type == ElementType.LabelRightAlign)
                    x += Width - textSurf.Width;
                else if (Type == ElementType.LabelCenterAlign)
                    x += (Width - textSurf.Width) / 2;

                surf.Blit (textSurf, new Point (x, 0));

                surf.TransparentColor = Color.Black /* XXX */;
                return surf;
            }
        }
开发者ID:directhex,项目名称:scsharp,代码行数:29,代码来源:LabelElement.cs


示例14: Setup

        private void Setup()
        {
            try
            {
                EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
            }
            catch (Direct3D9Exception)
            {
                //あれ?ABGRで無いとダメなん?
                EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default);
            }
            renderSurface = EdgeMap.GetSurfaceLevel(0);
            depthBuffer = Surface.CreateDepthStencil(SlimMMDXCore.Instance.Device, width, height, Format.D16, MultisampleType.None, 0, true);
            //エッジ用エフェクト読み込み
            if (effect != null)
            {
                effect.OnResetDevice();
            }
            else
            {
                effect = Effect.FromMemory(SlimMMDXCore.Instance.Device, MMDXResource.MMDEdgeEffect,
#if DEBUG
 ShaderFlags.OptimizationLevel0 | ShaderFlags.Debug
#else
                        ShaderFlags.OptimizationLevel3
#endif
);
            }
            effect.SetValue("EdgeWidth", EdgeWidth);
            effect.Technique = "MMDEdgeEffect";
            
            effect.SetValue("ScreenResolution", new Vector2(width, height));
            CreateScreenVertex();
        }
开发者ID:himapo,项目名称:ccm,代码行数:34,代码来源:EdgeManager.cs


示例15: CreateSurface

        protected override Surface CreateSurface()
        {
            if (ParentScreen.Background == null && ParentScreen.UseTiles) {
                Surface surf = new Surface (Width, Height);
                surf.Fill (new Rectangle (new Point (0,0), new Size (Width, Height)),
                       Color.FromArgb (0,0,0,0));
                surf.TransparentColor = Color.Black; /* XXX */

                Pcx pal = new Pcx ();
                pal.ReadFromStream ((Stream)Mpq.GetResource ("unit\\cmdbtns\\ticon.pcx"),
                            -1, -1);

                /* tile the top border */
                TileRow (surf, tileGrp, pal.Palette, TILE_TL, TILE_T, TILE_TR, 0);

                /* tile everything down to the bottom border */
                for (int y = tileGrp.Height - 2; y < surf.Height - tileGrp.Height; y += tileGrp.Height - 2)
                    TileRow (surf, tileGrp, pal.Palette, TILE_L, TILE_C, TILE_R, y);

                /* tile the bottom row */
                TileRow (surf, tileGrp, pal.Palette, TILE_BL, TILE_B, TILE_BR, surf.Height - tileGrp.Height);
                return surf;
            }
            else
                return null;
        }
开发者ID:directhex,项目名称:scsharp,代码行数:26,代码来源:DialogBoxElement.cs


示例16: BitmapHistoryMemento

        public BitmapHistoryMemento(string name, ImageResource image, IHistoryWorkspace historyWorkspace, 
            int layerIndex, PdnRegion changedRegion, Surface copyFromThisSurface)
            : base(name, image)
        {
            this.historyWorkspace = historyWorkspace;
            this.layerIndex = layerIndex;

            PdnRegion region = changedRegion.Clone();
            this.tempFileName = FileSystem.GetTempFileName();

            FileStream outputStream = null;

            try
            {
                outputStream = FileSystem.OpenStreamingFile(this.tempFileName, FileAccess.Write);
                SaveSurfaceRegion(outputStream, copyFromThisSurface, region);
            }

            finally
            {
                if (outputStream != null)
                {
                    outputStream.Dispose();
                    outputStream = null;
                }
            }

            this.tempFileHandle = new DeleteFileOnFree(this.tempFileName);
            BitmapHistoryMementoData data = new BitmapHistoryMementoData(null, region);

            this.Data = data;
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:32,代码来源:BitmapHistoryMemento.cs


示例17: D3D9DepthBuffer

        public D3D9DepthBuffer( PoolId poolId, D3DRenderSystem renderSystem,
            Device creator, Surface depthBufferSurf,
            Format fmt, int width, int height,
            MultisampleType fsaa, int multiSampleQuality,
            bool isManual) :
            base(poolId, 0, width, height, (int)fsaa, "", isManual)
        {
            depthBuffer = depthBufferSurf;
            this.creator = creator;
            this.multiSampleQuality = multiSampleQuality;
            d3dFormat = fmt;
            this.renderSystem = renderSystem;

            switch (fmt)
            {
                case Format.D16Lockable:
                case Format.D15S1:
                case Format.D16:
                    bitDepth = 16;
                    break;
                case Format.D32:
                case Format.D24S8:
                case Format.D24X8:
                case Format.D24X4S4:
                case Format.D32Lockable:
                case Format.D24SingleS8:
                    bitDepth = 32;
                    break;
            }
        }
开发者ID:WolfgangSt,项目名称:axiom,代码行数:30,代码来源:D3D9DepthBuffer.cs


示例18: TexturedPolygon

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="positionsX">array of x positions of points</param>
        /// <param name="positionsY">array of y positions of points</param>
        /// <param name="surface">Textured surface</param>
        /// <param name="textureOffsetX">Texture is offset on the X axis</param>
        /// <param name="textureOffsetY">Texture is offset on the Y axis</param>
        public TexturedPolygon(Surface surface, short[] positionsX, short[] positionsY, int textureOffsetX, int textureOffsetY)
        {
            if (positionsX == null)
            {
                throw new ArgumentNullException("positionsX");
            }
            if (positionsY == null)
            {
                throw new ArgumentNullException("positionsY");
            }
            this.x = positionsX;
            this.y = positionsY;
            this.n = 0;
            this.list = new ArrayList();
            this.xTotal = 0;
            this.yTotal = 0;
            this.texturedSurface = surface;
            this.textureOffsetX = textureOffsetX;
            this.textureOffsetY = textureOffsetY;

            if (x.Length != y.Length)
            {
                throw SdlException.Generate();
            }
            else
            {
                this.n = x.Length;
            }
        }
开发者ID:ywjno,项目名称:mynes-code,代码行数:37,代码来源:TexturedPolygon.cs


示例19: SurfaceSprite

        public SurfaceSprite(Surface surface, Point2 location)
        {
            Contract.Requires(surface != null);

            _surface = surface;
            _location = location;
        }
开发者ID:exKAZUu,项目名称:Paraiba,代码行数:7,代码来源:SurfaceSprite.cs


示例20: MinimapRender

        public MinimapRender()
        {
            mRenderTarget = new Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device,
                2048, 2048, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            mRenderSurface = mRenderTarget.GetSurfaceLevel(0);
        }
开发者ID:remixod,项目名称:sharpwow,代码行数:7,代码来源:MinimapRender.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SurfaceFormat类代码示例发布时间:2022-05-24
下一篇:
C# SupportedLanguage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap