本文整理汇总了C#中Size2类的典型用法代码示例。如果您正苦于以下问题:C# Size2类的具体用法?C# Size2怎么用?C# Size2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Size2类属于命名空间,在下文中一共展示了Size2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProgressBar
public ProgressBar(GUIControl parent)
: base("", parent)
{
size= new Size2(120, 32);
pHorizontal= true;
pProgress= 0f;
pAutoLabel= true;
pProgressColors= new GUIColorPacket
(
new Color(0, 200, 0),
new Color(230, 230, 230),
new Color(0, 200, 150),
new Color(0, 150, 150)
);
pProgressLeftColors= new GUIColorPacket
(
new Color(200, 0, 0),
new Color(100, 100, 100),
new Color(200, 100, 50),
new Color(200, 0, 0)
);
pAutoAdjustSize= false;
pBGColors.normal= new Color(25, 25, 25);
pBGColors.disabled= new Color(0, 0, 0);
addEvent("onProgressChanged");
addEvent("onProgressColorsChanged");
addEvent("onProgressLeftColorsChanged");
}
示例2: Rectangle2
public Rectangle2(Point2 point, Size2 sizeF)
{
X = point.X;
Y = point.Y;
Width = sizeF.Width;
Height = sizeF.Height;
}
示例3: MemoryMappedTexture32bpp
/// <summary>
/// Initializes a new instance of the <see cref="MemoryMappedTexture32bpp"/> class.
/// </summary>
/// <param name="size">The total size of the texture.</param>
public MemoryMappedTexture32bpp(Size2 size)
{
m_pointer = Marshal.AllocHGlobal(size.Width * size.Height * 4);
m_pointerNative = (int*)m_pointer.ToPointer();
m_size = size;
m_countInts = m_size.Width * m_size.Height;
}
示例4: init
protected override void init(Stream stream, bool flip, Loader.LoadedCallbackMethod loadedCallback)
{
try
{
using (var imageData = NSData.FromStream(stream))
using (var image = UIImage.LoadFromData(imageData))
{
int width = (int)image.Size.Width;
int height = (int)image.Size.Height;
Mipmaps = new Mipmap[1];
Size = new Size2(width, height);
var data = new byte[width * height * 4];
using (CGContext imageContext = new CGBitmapContext(data, width, height, 8, width*4, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedLast))
{
imageContext.DrawImage(new RectangleF(0, 0, width, height), image.CGImage);
Mipmaps[0] = new Mipmap(data, width, height, 1, 4);
if (flip) Mipmaps[0].FlipVertical();
}
}
}
catch (Exception e)
{
FailedToLoad = true;
Loader.AddLoadableException(e);
if (loadedCallback != null) loadedCallback(this, false);
return;
}
Loaded = true;
if (loadedCallback != null) loadedCallback(this, true);
}
示例5: SDXBitmapFromSysBitmap
private SharpDX.Direct2D1.Bitmap SDXBitmapFromSysBitmap(WindowRenderTarget device, System.Drawing.Bitmap bitmap)
{
var sourceArea = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
var bitmapProperties = new BitmapProperties(new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied));
var size = new Size2(bitmap.Width, bitmap.Height);
// Transform pixels from BGRA to RGBA
int stride = bitmap.Width * sizeof(int);
using (var tempStream = new DataStream(bitmap.Height * stride, true, true))
{
// Lock System.Drawing.Bitmap
var bitmapData = bitmap.LockBits(sourceArea, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
// Convert all pixels
for (int y = 0; y < bitmap.Height; y++)
{
int offset = bitmapData.Stride * y;
for (int x = 0; x < bitmap.Width; x++)
{
// Not optimized
byte B = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte G = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte R = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte A = Marshal.ReadByte(bitmapData.Scan0, offset++);
int rgba = R | (G << 8) | (B << 16) | (A << 24);
tempStream.Write(rgba);
}
}
bitmap.UnlockBits(bitmapData);
tempStream.Position = 0;
return new SharpDX.Direct2D1.Bitmap(device, size, tempStream, stride, bitmapProperties);
}
}
示例6: Initialize
/// <summary>Initializes the specified view.</summary>
/// <param name="view">The view.</param>
/// <exception cref="System.ArgumentException">Expecting argument to be a ShaderResourceView or RenderTargetView;view</exception>
protected override void Initialize(DeviceChild view)
{
// The initialize method will override the view.Tag, so we are setting it back
base.Initialize(view);
IsRenderView = view is RenderTargetView;
var shaderResourceView = view as ShaderResourceView;
int mipLevel = 0;
if (shaderResourceView != null)
{
var description = shaderResourceView.Description;
mipLevel = description.Texture1D.MostDetailedMip;
}
else
{
var renderTargetView = view as RenderTargetView;
if (renderTargetView == null)
{
throw new ArgumentException("Expecting argument to be a ShaderResourceView or RenderTargetView", "view");
}
mipLevel = renderTargetView.Description.Texture1D.MipSlice;
}
Size = new Size2(Math.Max(1, Texture.Width >> mipLevel), Math.Max(1, Texture.Height >> mipLevel));
TexelSize = new Size2F
{
Width = 1.0f / Size.Width,
Height = 1.0f / Size.Height
};
}
示例7: New
public static IViewPort New(VideoTypes videoType, IDisposableResource parent, Point2 location, Size2 size)
{
IViewPort api = null;
#if WIN32
if (videoType == VideoTypes.D3D9) api = new D3D9.ViewPort(parent, location, size);
#endif
#if WIN32 || WINRT || WP8
if (videoType == VideoTypes.D3D11) api = new D3D11.ViewPort(parent, location, size);
#endif
#if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl
if (videoType == VideoTypes.OpenGL) api = new OpenGL.ViewPort(parent, location, size);
#endif
#if XNA
if (videoType == VideoTypes.XNA) api = new XNA.ViewPort(parent, location, size);
#endif
#if VITA
if (videoType == VideoTypes.Vita) api = new Vita.ViewPort(parent, location, size);
#endif
if (api == null) Debug.ThrowError("ViewPortAPI", "Unsuported InputType: " + videoType);
return api;
}
示例8: DX11Renderer
public DX11Renderer(IntPtr windowHandle, Size2 size, Device dev = null)
{
RenderSize = size;
_windowHandle = windowHandle;
if(dev != null)
{
_dxDevice = dev;
}
else
{
var swapchainDesc = new SwapChainDescription()
{
BufferCount = 2,
ModeDescription =
new ModeDescription(size.Width, size.Height,
new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = windowHandle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
// Create Device and SwapChain
Device.CreateWithSwapChain(DriverType.Hardware,
DeviceCreationFlags.None, swapchainDesc, out _dxDevice, out _swapChain);
// Ignore all windows events
// var factory = _swapChain.GetParent<Factory>();
// factory.MakeWindowAssociation(windowHandle, WindowAssociationFlags.None);
Reset(size.Width, size.Height);
}
}
示例9: WorldToScreen
public static Vector2[] WorldToScreen(Matrix4x4 viewMatrix, Size2 screenSize, params Vector3[] points)
{
Vector2[] worlds = new Vector2[points.Length];
for (int i = 0; i < worlds.Length; i++)
worlds[i] = WorldToScreen(viewMatrix, screenSize, points[i]);
return worlds;
}
示例10: DirectXTexture
/// <summary>
/// Initializes a new DirectXTexture class.
/// </summary>
/// <param name="bmp">The Bitmap.</param>
internal DirectXTexture(System.Drawing.Bitmap bmp)
{
RawBitmap = (System.Drawing.Bitmap) bmp.Clone();
_width = bmp.Width;
_height = bmp.Height;
var sourceArea = new Rectangle(0, 0, bmp.Width, bmp.Height);
var bitmapProperties = new BitmapProperties(
new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), 96, 96);
var size = new Size2(bmp.Width, bmp.Height);
int stride = bmp.Width*sizeof (int);
using (var tempStream = new DataStream(bmp.Height*stride, true, true))
{
BitmapData bitmapData = bmp.LockBits(sourceArea, ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
for (int y = 0; y < bmp.Height; y++)
{
int offset = bitmapData.Stride*y;
for (int x = 0; x < bmp.Width; x++)
{
byte b = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte g = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte r = Marshal.ReadByte(bitmapData.Scan0, offset++);
byte a = Marshal.ReadByte(bitmapData.Scan0, offset++);
int rgba = r | (g << 8) | (b << 16) | (a << 24);
tempStream.Write(rgba);
}
}
bmp.UnlockBits(bitmapData);
tempStream.Position = 0;
_bmp = new Bitmap(DirectXHelper.RenderTarget, size, tempStream, stride, bitmapProperties);
}
}
示例11: Size2_IsConstructedProperly
public void Size2_IsConstructedProperly()
{
var result = new Size2(123, 456);
TheResultingValue(result)
.ShouldBe(123, 456);
}
示例12: init
protected override void init(Stream stream, bool flip, Loader.LoadedCallbackMethod loadedCallback)
{
try
{
using (var image = NSImage.FromStream(stream))
{
var rep = image.Representations()[0];
int width = rep.PixelsWide;
int height = rep.PixelsHigh;
Mipmaps = new Mipmap[1];
Size = new Size2(width, height);
var data = new byte[width * height * 4];
var emptyRect = RectangleF.Empty;
using (CGContext imageContext = new CGBitmapContext(data, width, height, 8, width*4, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedLast))
using (var cgImage = image.AsCGImage(ref emptyRect, null, null))
{
imageContext.DrawImage(new RectangleF(0, 0, width, height), cgImage);
Mipmaps[0] = new Mipmap(data, width, height, 1, 4);
if (flip) Mipmaps[0].FlipVertical();
}
}
}
catch (Exception e)
{
FailedToLoad = true;
Loader.AddLoadableException(e);
if (loadedCallback != null) loadedCallback(this, false);
return;
}
Loaded = true;
if (loadedCallback != null) loadedCallback(this, true);
}
示例13: Size2_Area_IsCalculatedCorrectly
public void Size2_Area_IsCalculatedCorrectly()
{
var size1 = new Size2(123, 456);
TheResultingValue(size1.Area).ShouldBe(123 * 456);
var size2 = new Size2(222, 55555);
TheResultingValue(size2.Area).ShouldBe(222 * 55555);
}
示例14: Size2_EqualsObject
public void Size2_EqualsObject()
{
var size1 = new Size2(123, 456);
var size2 = new Size2(123, 456);
TheResultingValue(size1.Equals((Object)size2)).ShouldBe(true);
TheResultingValue(size1.Equals("This is a test")).ShouldBe(false);
}
示例15: GetTextureClip
public SharpDX.RectangleF GetTextureClip(Size2 outputSize)
{
lock (_imageSync)
{
Size imageSize = ImageSize;
SharpDX.RectangleF textureClip = _animator.GetZoomRect(new Size2(imageSize.Width, imageSize.Height), outputSize, DateTime.Now);
return new SharpDX.RectangleF(textureClip.X * _textureMaxUv.Width, textureClip.Y * _textureMaxUv.Height, textureClip.Width * _textureMaxUv.Width, textureClip.Height * _textureMaxUv.Height);
}
}