本文整理汇总了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;
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例14: GetSprite
public static Sprite GetSprite()
{
try
{
_sprite = new Sprite(Drawing.Direct3DDevice);
}
catch (Exception e)
{
Console.WriteLine(@"An error occurred: '{0}'", e);
}
return _sprite;
}
示例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);
}