當前位置: 首頁>>代碼示例>>C#>>正文


C# Direct3D9.Sprite類代碼示例

本文整理匯總了C#中SharpDX.Direct3D9.Sprite的典型用法代碼示例。如果您正苦於以下問題:C# Sprite類的具體用法?C# Sprite怎麽用?C# Sprite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Sprite類屬於SharpDX.Direct3D9命名空間,在下文中一共展示了Sprite類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ConvertToBitmap

        public Bitmap ConvertToBitmap(string filePath)
        {
            using (var texture = Texture.FromFile(device, filePath)) {
            var surfaceDescription = texture.GetLevelDescription(0);
            var textureWidth = surfaceDescription.Width;
            var textureHeight = surfaceDescription.Height;

            using (var renderTarget = Surface.CreateRenderTarget(device, textureWidth, textureHeight, Format.X8R8G8B8, MultisampleType.None, 0, true)) {
               var oldBackBuffer = device.GetRenderTarget(0);

               device.SetRenderTarget(0, renderTarget);
               using (var sprite = new Sprite(device)) {
                  device.BeginScene();
                  sprite.Begin(SpriteFlags.AlphaBlend);
                  sprite.Draw(texture, new ColorBGRA(Vector4.One));
                  sprite.End();
                  device.EndScene();
               }
               device.SetRenderTarget(0, oldBackBuffer);

               var renderTargetData = renderTarget.LockRectangle(LockFlags.ReadOnly);
               var resultBitmap = new Bitmap(textureWidth, textureHeight);
               var resultData = resultBitmap.LockBits(new Rectangle(0, 0, textureWidth, textureHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
               for (var y = 0; y < textureHeight; y++) {
                  Utilities.CopyMemory(resultData.Scan0 + y * resultData.Stride, renderTargetData.DataPointer + y * renderTargetData.Pitch, textureWidth * 4);
               }
               resultBitmap.UnlockBits(resultData);
               renderTarget.UnlockRectangle();
               return resultBitmap;
            }
             }
        }
開發者ID:ItzWarty,項目名稱:the-dargon-project,代碼行數:32,代碼來源:TextureConverter.cs

示例2: Initialise

        public bool Initialise(Device device)
        {
            Debug.Assert(!_initialised);
            if (_initialising)
                return false;

            _initialising = true;

            try
            {

                _device = device;

                _sprite = ToDispose(new Sprite(_device));

                // Initialise any resources required for overlay elements
                IntialiseElementResources();

                _initialised = true;
                return true;
            }
            finally
            {
                _initialising = false;
            }
        }
開發者ID:Fujimuji,項目名稱:Direct3DHook,代碼行數:26,代碼來源:DXOverlayEngine.cs

示例3: SkillBar

        public SkillBar(Menu config)
        {
            MenuSkillBar = config.AddSubMenu(new Menu("Cooldown Tracker", "SkillBar"));
            MenuSkillBar.AddItem(new MenuItem("OnAllies", "On Allies").SetValue(false));
            MenuSkillBar.AddItem(new MenuItem("OnEnemies", "On Enemies").SetValue(true));
            Sprite = new Sprite(Drawing.Direct3DDevice);
            HudTexture = Texture.FromMemory(
                Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.main, typeof(byte[])), 127, 41,
                0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
            FrameLevelTexture = Texture.FromMemory(
                Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.spell_level, typeof(byte[])),
                2, 3, 0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
            ButtonRedTexture = Texture.FromMemory(
                Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.disable, typeof(byte[])), 14,
                14, 0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
            SmallText = new Font(
                Drawing.Direct3DDevice,
                new FontDescription
                {
                    FaceName = "Calibri",
                    Height = 13,
                    OutputPrecision = FontPrecision.Default,
                    Quality = FontQuality.Default,
                });

            AppDomain.CurrentDomain.DomainUnload += DomainUnload;
            AppDomain.CurrentDomain.ProcessExit += DomainUnload;
            CustomEvents.Game.OnGameLoad += Game_OnGameLoad;
        }
開發者ID:AwkwardDev,項目名稱:LeagueSharp2,代碼行數:29,代碼來源:SkillBar.cs

示例4: BlurComponent

        public BlurComponent(Device graphics, int size)
        {
            _graphics = graphics;

            Dims = size;
            Format = Format.A8R8G8B8;

            _sampleOffsetsHoriz = new Vector4D[SampleCount];
            _sampleOffsetsVert = new Vector4D[SampleCount];

            _sampleWeightsHoriz = new float[SampleCount];
            _sampleWeightsVert = new float[SampleCount];

            int width = Dims - 5;
            int height = Dims - 5;

            SetBlurEffectParameters(1.0f / width, 0, ref _sampleOffsetsHoriz, ref _sampleWeightsHoriz);
            SetBlurEffectParameters(0, 1.0f / height, ref _sampleOffsetsVert, ref _sampleWeightsVert);

            _effect = new GaussianBlurEffect(_graphics);

            OutputTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
            _intermediateTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);

            _sprite = new Sprite(_graphics);
        }
開發者ID:tgjones,項目名稱:meshellator,代碼行數:26,代碼來源:BlurComponent.cs

示例5: GetCenteredText

 /// <summary>
 ///     Calculates the center position for the given text on within a rectangle boundaries.
 /// </summary>
 /// <param name="rectangle">Rectangle boundaries</param>
 /// <param name="sprite">Sprite which is being drawn on</param>
 /// <param name="text">The Text</param>
 /// <param name="flags">Centered Flags</param>
 /// <returns>Returns the center position of the text on the rectangle.</returns>
 public static Vector2 GetCenteredText(
     this SharpDX.Rectangle rectangle,
     Sprite sprite,
     string text,
     CenteredFlags flags)
 {
     return rectangle.GetCenter(sprite, Constants.LeagueSharpFont.MeasureText(sprite, text, 0), flags);
 }
開發者ID:parkyoungsoo,項目名稱:LeagueSharp.SDK,代碼行數:16,代碼來源:Geometry.cs

示例6: HpBarIndicator

        public HpBarIndicator()
        {
            dxLine = new Line(dxDevice) { Width = 9 };
            sprite = new Sprite(dxDevice);

            Drawing.OnPreReset += DrawingOnOnPreReset;
            Drawing.OnPostReset += DrawingOnOnPostReset;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
            AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnDomainUnload;
        }
開發者ID:Merc491,項目名稱:GoodGuyJodu,代碼行數:10,代碼來源:HpBarIndicator.cs

示例7: DeathDraw

        public DeathDraw()
        {
            dxLine = new Line(dxDevice) { Width = 9 };
            sprite = new Sprite(dxDevice);

            Drawing.OnPreReset += DrawingOnOnPreReset;
            Drawing.OnPostReset += DrawingOnOnPostReset;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
            AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnDomainUnload;
            windowsH = dxDevice.Viewport.Height;
            windowsW = dxDevice.Viewport.Width;
            Console.WriteLine("Xtest: " + dxDevice.Viewport.Width + " : " + dxDevice.Viewport.Height);

        }
開發者ID:Sthephanfelix,項目名稱:LeagueSharp-4,代碼行數:14,代碼來源:DeathDraw.cs

示例8: Game_OnGameLoad

 static void Game_OnGameLoad(EventArgs args)
 {
     Game.PrintChat("Unban.exe By DZ191 Loaded. Credits to DETUKS");
     sprite = new Sprite(dxDevice);
    taco = Texture.FromMemory(
             Drawing.Direct3DDevice,
             (byte[])new ImageConverter().ConvertTo(LoadPicture("http://puu.sh/cP1qD/d23cd24220.jpg"), typeof(byte[])), 513, 744, 0,
             Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
     Drawing.OnEndScene += Drawing_OnEndScene;
     Drawing.OnPreReset += DrawingOnOnPreReset;
     Drawing.OnPostReset += DrawingOnOnPostReset;
     AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
     AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnDomainUnload;
 }
開發者ID:luizssn,項目名稱:LeagueSharp,代碼行數:14,代碼來源:Program.cs

示例9: MeasureText

        public static Rectangle MeasureText(this Font font, Sprite sprite, string text)
        {
            Dictionary<string, Rectangle> rectangles;
            if (!Widths.TryGetValue(font, out rectangles))
            {
                rectangles = new Dictionary<string, Rectangle>();
                Widths[font] = rectangles;
            }

            Rectangle rectangle;
            if (rectangles.TryGetValue(text, out rectangle))
            {
                return rectangle;
            }
            rectangle = font.MeasureText(sprite, text, 0);
            rectangles[text] = rectangle;
            return rectangle;
        }
開發者ID:nguyenduykhai123,項目名稱:L-Assemblies,代碼行數:18,代碼來源:Render.cs

示例10: InitTexture

    private void InitTexture(BluRayAPI.OSDTexture item)
    {
      if (item.Width == 0 || item.Height == 0 || item.Texture == IntPtr.Zero)
      {
        FreeResources();
        return;
      }

      if (_combinedOsdTexture == null || _combinedOsdTexture.IsDisposed)
      {
        _combinedOsdTexture = new Texture(_device, _fullOsdSize.Width, _fullOsdSize.Height, 1, Usage.RenderTarget, FORMAT, Pool.Default);
        _combinedOsdSurface = _combinedOsdTexture.GetSurfaceLevel(0);

        _sprite = new Sprite(_device);

        Rectangle dstRect = new Rectangle(0, 0, _fullOsdSize.Width, _fullOsdSize.Height);
        _device.ColorFill(_combinedOsdSurface, dstRect, _transparentColor);
      }
    }
開發者ID:davinx,項目名稱:MediaPortal-2,代碼行數:19,代碼來源:BluRayOSDRenderer.cs

示例11: HbTracker

        static HbTracker()
        {
            if (!Game.Version.Contains("4.19"))
            {
                SummonerSpellSlots = new[] { SpellSlot.Q, SpellSlot.W };
            }

            try
            {
                foreach (var sName in SummonersNames)
                {
                    SummonerTextures.Add(sName, GetSummonerTexture(sName));
                }

                Sprite = new Sprite(Drawing.Direct3DDevice);
                CdFrameTexture = Texture.FromMemory(
                    Drawing.Direct3DDevice,
                    (byte[]) new ImageConverter().ConvertTo(Properties.Resources.hud, typeof(byte[])), 147, 27, 0,
                    Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);

                ReadyLine = new Line(Drawing.Direct3DDevice) { Width = 2 };

                Text = new Font(
                    Drawing.Direct3DDevice,
                    new FontDescription
                    {
                        FaceName = "Calibri",
                        Height = 13,
                        OutputPrecision = FontPrecision.Default,
                        Quality = FontQuality.Default,
                    });
            }
            catch (Exception e)
            {
                Console.WriteLine(@"/ff can't load the textures: " + e);
            }

            Drawing.OnPreReset += DrawingOnOnPreReset;
            Drawing.OnPostReset += DrawingOnOnPostReset;
            Drawing.OnDraw += Drawing_OnEndScene;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
            AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnDomainUnload;
        }
開發者ID:lanyi777,項目名稱:CN,代碼行數:43,代碼來源:HbTracker.cs

示例12: Tracker

        static Tracker()
        {
            foreach (var sName in SummonersNames)
                SummonerTextures.Add(sName.ToLower(), GetSummonerTexture(sName.ToLower()));
            foreach (var slot in SpellSlots)
                SpellTextures.Add(slot.ToString(), GetSpellTexture(slot.ToString()));

            Sprite = new Sprite(Drawing.Direct3DDevice);
            TextureOther = Texture.FromMemory(
            Drawing.Direct3DDevice,
            (byte[])new ImageConverter().ConvertTo(Properties.Resources.Healthbar_Tracker_Others, typeof(byte[])), 131, 17, 0,
            Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
            TextureMe = Texture.FromMemory(
            Drawing.Direct3DDevice,
            (byte[])new ImageConverter().ConvertTo(Properties.Resources.Healthbar_Tracker2, typeof(byte[])), 131, 17, 0,
            Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
            Drawing.OnPreReset += DrawingOnOnPreReset;
            Drawing.OnPostReset += DrawingOnOnPostReset;
            Drawing.OnDraw += Drawing_OnDraw;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
            AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnDomainUnload;
        }
開發者ID:lanyi777,項目名稱:CN,代碼行數:22,代碼來源:Tracker.cs

示例13: GetCenter

        /// <summary>
        ///     Returns the center position of the rendering object on the rectangle.
        /// </summary>
        /// <param name="rectangle">Rectangle boundaries</param>
        /// <param name="sprite">Sprite which is being drawn on</param>
        /// <param name="dimensions">Object Dimensions</param>
        /// <param name="flags">Centered Flags</param>
        /// <returns>Vector2 center position of the rendering object on the rectangle.</returns>
        public static Vector2 GetCenter(
            this Rectangle rectangle, 
            Sprite sprite, 
            Rectangle dimensions, 
            CenteredFlags flags)
        {
            var x = 0;
            var y = 0;

            if (flags.HasFlag(CenteredFlags.HorizontalLeft))
            {
                x = rectangle.TopLeft.X;
            }
            else if (flags.HasFlag(CenteredFlags.HorizontalCenter))
            {
                x = rectangle.TopLeft.X + (rectangle.Width - dimensions.Width) / 2;
            }
            else if (flags.HasFlag(CenteredFlags.HorizontalRight))
            {
                x = rectangle.TopRight.X - dimensions.Width;
            }

            if (flags.HasFlag(CenteredFlags.VerticalUp))
            {
                y = rectangle.TopLeft.Y;
            }
            else if (flags.HasFlag(CenteredFlags.VerticalCenter))
            {
                y = rectangle.TopLeft.Y + (rectangle.Height - dimensions.Height) / 2;
            }
            else if (flags.HasFlag(CenteredFlags.VerticalDown))
            {
                y = rectangle.BottomLeft.Y - dimensions.Height;
            }

            return new Vector2(x, y);
        }
開發者ID:8569482,項目名稱:LeagueSharp.SDK,代碼行數:45,代碼來源:Geometry.cs

示例14: GetSprite

 public static Sprite GetSprite()
 {
     try
     {
         _sprite = new Sprite(Drawing.Direct3DDevice);
     }
     catch (Exception e)
     {
         Console.WriteLine(@"An error occurred: '{0}'", e);
     }
     return _sprite;
 }
開發者ID:yashine59fr,項目名稱:PortAIO-1,代碼行數:12,代碼來源:MDrawing.cs

示例15: GetCenteredText

 /// <summary>
 ///     Calculates the center position for the given text on within a rectangle boundaries.
 /// </summary>
 /// <param name="rectangle">Rectangle boundaries</param>
 /// <param name="sprite">Sprite which is being drawn on</param>
 /// <param name="font">Text Font</param>
 /// <param name="text">The Text</param>
 /// <param name="flags">Centered Flags</param>
 /// <returns>Returns the center position of the text on the rectangle.</returns>
 public static Vector2 GetCenteredText(
     this Rectangle rectangle, 
     Sprite sprite, 
     Font font, 
     string text, 
     CenteredFlags flags)
 {
     return font == null
                ? rectangle.GetCenteredText(sprite, text, flags)
                : rectangle.GetCenter(sprite, font.MeasureText(sprite, text, 0), flags);
 }
開發者ID:8569482,項目名稱:LeagueSharp.SDK,代碼行數:20,代碼來源:Geometry.cs


注:本文中的SharpDX.Direct3D9.Sprite類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。