本文整理汇总了C#中SiliconStudio.TextureConverter.TexImage.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TexImage.Clone方法的具体用法?C# TexImage.Clone怎么用?C# TexImage.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.TextureConverter.TexImage
的用法示例。
在下文中一共展示了TexImage.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
/// <summary>
/// Saves the specified <see cref="TexImage"/> into a file with the specified format.
/// </summary>
/// <param name="image">The image.</param>
/// <param name="fileName">Name of the file.</param>
/// <param name="format">The new format.</param>
/// <param name="minimumMipMapSize">Minimum size of the mip map.</param>
public void Save(TexImage image, String fileName, PixelFormat format, int minimumMipMapSize = 1)
{
if (fileName == null || fileName.Equals(""))
{
Log.Error("No file name entered.");
throw new TextureToolsException("No file name entered.");
}
if (minimumMipMapSize < 0)
{
Log.Error("The minimup Mipmap size can't be negative. Put 0 or 1 for a complete Mipmap chain.");
throw new TextureToolsException("The minimup Mipmap size can't be negative. Put 0 or 1 for a complete Mipmap chain.");
}
if (image.Format != format && format.IsCompressed() && !image.Format.IsCompressed())
{
TexImage workingImage = (TexImage)image.Clone();
Compress(workingImage, format);
ExecuteRequest(workingImage, new ExportRequest(fileName, minimumMipMapSize));
workingImage.Dispose();
}
else if (image.Format != format && format.IsCompressed())
{
TexImage workingImage = (TexImage)image.Clone();
Decompress(workingImage, image.Format.IsSRgb());
Compress(workingImage, format);
ExecuteRequest(workingImage, new ExportRequest(fileName, minimumMipMapSize));
workingImage.Dispose();
}
else
{
ExecuteRequest(image, new ExportRequest(fileName, minimumMipMapSize));
}
}
示例2: CreateImageFromAlphaComponent
/// <summary>
/// Create a new image from the alpha component of a reference image.
/// </summary>
/// <param name="texImage">The image from which to take the alpha</param>
/// <returns>The <see cref="TexImage"/> containing the alpha component as rgb color. Note: it is the user responsibility to dispose the returned image.</returns>
public unsafe TexImage CreateImageFromAlphaComponent(TexImage texImage)
{
if (texImage.Dimension != TexImage.TextureDimension.Texture2D || texImage.Format.IsCompressed())
throw new NotImplementedException();
var alphaImage = (TexImage)texImage.Clone(true);
var rowPtr = alphaImage.Data;
for (int i = 0; i < alphaImage.Height; i++)
{
var pByte = (byte*)rowPtr;
for (int x = 0; x < alphaImage.Width; x++)
{
pByte[0] = pByte[3];
pByte[1] = pByte[3];
pByte[2] = pByte[3];
pByte += 4;
}
rowPtr = IntPtr.Add(rowPtr, alphaImage.RowPitch);
}
return alphaImage;
}
示例3: CreateImageFromAlphaComponent
/// <summary>
/// Create a new image from the alpha component of a reference image.
/// </summary>
/// <param name="texImage">The image from which to take the alpha</param>
/// <returns>The <see cref="TexImage"/> containing the alpha component as rgb color. Note: it is the user responsibility to dispose the returned image.</returns>
public unsafe TexImage CreateImageFromAlphaComponent(TexImage texImage)
{
var alphaImage = (TexImage)texImage.Clone(true);
var rowPtr = alphaImage.Data;
for (int i = 0; i < alphaImage.Height; i++)
{
var pByte = (byte*)rowPtr;
for (int x = 0; x < alphaImage.Width; x++)
{
pByte[0] = pByte[3];
pByte[1] = pByte[3];
pByte[2] = pByte[3];
pByte += 4;
}
rowPtr = IntPtr.Add(rowPtr, alphaImage.RowPitch);
}
return alphaImage;
}