本文整理汇总了C#中Texture.SetImage方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.SetImage方法的具体用法?C# Texture.SetImage怎么用?C# Texture.SetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.SetImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(float x, float y, float width, float height)
{
lock (textureLock)
{
try
{
if (texture != null)
{
texture.Dispose();
texture = null;
}
//if (File.Exists(imageFile))
//{
var c = new WebClient();
var bytes = c.DownloadData(_serverUrl + "liveview.jpg");
var ms = new MemoryStream(bytes);
BitmapImage src = new BitmapImage();
src.BeginInit();
src.CacheOption = BitmapCacheOption.OnLoad;
src.StreamSource = ms;
src.EndInit();
WriteableBitmap wb = new WriteableBitmap(new FormatConvertedBitmap(src, PixelFormats.Bgra32, null, 0));
texture = GS.CreateTexture((UInt32)wb.PixelWidth, (UInt32)wb.PixelHeight, GSColorFormat.GS_BGRA, null, false, false);
texture.SetImage(wb.BackBuffer, GSImageFormat.GS_IMAGEFORMAT_BGRA, (UInt32)(wb.PixelWidth * 4));
config.Parent.SetInt("cx", wb.PixelWidth);
config.Parent.SetInt("cy", wb.PixelHeight);
Size.X = (float)wb.PixelWidth;
Size.Y = (float)wb.PixelHeight;
GS.DrawSprite(texture, 0xFFFFFFFF, x, y, x + width, y + height);
}
catch (Exception exception)
{
this.Api.Log(exception.Message);
}
//}
//else
//{
// texture = null;
//}
}
}
示例2: LoadTexture
private void LoadTexture(String imageFile)
{
lock (textureLock)
{
if (texture != null)
{
texture.Dispose();
texture = null;
}
if (File.Exists(imageFile))
{
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(imageFile);
src.EndInit();
WriteableBitmap wb = new WriteableBitmap(src);
texture = GS.CreateTexture((UInt32)wb.PixelWidth, (UInt32)wb.PixelHeight, GSColorFormat.GS_BGRA, null, false, false);
texture.SetImage(wb.BackBuffer, GSImageFormat.GS_IMAGEFORMAT_BGRA, (UInt32)(wb.PixelWidth * 4));
config.Parent.SetInt("cx", wb.PixelWidth);
config.Parent.SetInt("cy", wb.PixelHeight);
Size.X = (float)wb.PixelWidth;
Size.Y = (float)wb.PixelHeight;
}
else
{
texture = null;
}
}
}