当前位置: 首页>>代码示例>>C#>>正文


C# TexImage.Clone方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:Kurooka,项目名称:paradox,代码行数:41,代码来源:TextureTool.cs

示例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;
        }
开发者ID:Kurooka,项目名称:paradox,代码行数:29,代码来源:TextureTool.cs

示例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;
        }
开发者ID:robterrell,项目名称:paradox,代码行数:26,代码来源:TextureTool.cs


注:本文中的SiliconStudio.TextureConverter.TexImage.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。