本文整理汇总了C#中Texture2D.Lock方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.Lock方法的具体用法?C# Texture2D.Lock怎么用?C# Texture2D.Lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.Lock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTextureFromColor
public static Texture2D CreateTextureFromColor(int width, int heigth, Color color)
{
var tex = new Texture2D(width, heigth);
tex.Lock();
for (var x = 0; x < width; x++)
{
for (var y = 0; y < heigth; y++)
{
tex[x, y] = color;
}
}
tex.Unlock();
return tex;
}
示例2: Grayscale
public static Texture2D Grayscale(this Texture2D tex)
{
var newTex = new Texture2D(tex.Width, tex.Height);
newTex.Lock();
tex.Lock();
for (var x = 0; x < tex.Width; x++)
{
for (var y = 0; y < tex.Height; y++)
{
var orginalColor = tex[x, y];
var grayscale = (int) ((orginalColor.R*0.3) + (orginalColor.G*0.59) + (orginalColor.B*0.11));
var newColor = Color.FromArgb(orginalColor.A, grayscale, grayscale, grayscale);
newTex[x, y] = newColor;
}
}
tex.Unlock();
newTex.Unlock();
return newTex;
}
示例3: CreateBorderFromColor
public static Texture2D CreateBorderFromColor(int width, int heigth, int penLength, Color color)
{
var tex = new Texture2D(width, heigth);
tex.Lock();
for (var x = 0; x <= width - 1; x++)
{
for (var y = 0; y <= heigth - 1; y++)
if ((penLength - x) > 0 || (penLength + x) > width - 1)
tex[x, y] = color;
}
for (var y = 0; y <= heigth - 1; y++)
{
for (var x = 0; x <= width - 1; x++)
if ((penLength - y) > 0 || (penLength + y) > heigth - 1)
tex[x, y] = color;
}
tex.Unlock();
return tex;
}