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


C# TexImage.Clone方法代码示例

本文整理汇总了C#中TexImage.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TexImage.Clone方法的具体用法?C# TexImage.Clone怎么用?C# TexImage.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TexImage的用法示例。


在下文中一共展示了TexImage.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Extract

        /// <summary>
        /// Extracts one or every texture from a texture array.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="request">The request.</param>
        private void Extract(TexImage image, ArrayExtractionRequest request)
        {
            int subImageCount = image.SubImageArray.Length / image.ArraySize;

            // Retrieving the mipmap count and the subimage count corresponding to the minimum mipmap size requested
            int subImageCountWanted = 0;
            int newMipMapCount = 0;
            int curDepth = image.Depth == 1 ? 1 : image.Depth << 1;
            for (int i = 0; i < image.MipmapCount; ++i)
            {
                curDepth = curDepth > 1 ? curDepth >>= 1 : curDepth;

                if (image.SubImageArray[subImageCountWanted].Width <= request.MinimumMipMapSize || image.SubImageArray[subImageCountWanted].Height <= request.MinimumMipMapSize)
                {
                    subImageCountWanted += curDepth;
                    ++newMipMapCount;
                    break;
                }
                ++newMipMapCount;
                subImageCountWanted += curDepth;
            }

            if (request.Indice != -1)
            {
                Log.Info("Extracting texture " + request.Indice + " from the texture array ...");

                request.Texture = (TexImage)image.Clone(false);
                request.Texture.ArraySize = 1;
                request.Texture.MipmapCount = newMipMapCount;

                request.Texture.SubImageArray = new TexImage.SubImage[subImageCountWanted];

                int dataSize = 0;
                for (int i = 0; i < subImageCountWanted; ++i)
                {
                    request.Texture.SubImageArray[i] = image.SubImageArray[request.Indice * subImageCount + i];
                    dataSize += request.Texture.SubImageArray[i].SlicePitch;
                }

                request.Texture.Data = request.Texture.SubImageArray[0].Data;
                request.Texture.DataSize = dataSize;
            }
            else
            {
                Log.Info("Extracting each texture from the texture array ...");

                TexImage texture;
                for (int i = 0; i < image.ArraySize; ++i)
                {
                    texture = (TexImage)image.Clone(false);
                    texture.ArraySize = 1;
                    texture.SubImageArray = new TexImage.SubImage[subImageCountWanted];
                    texture.MipmapCount = newMipMapCount;

                    int dataSize = 0;
                    for (int j = 0; j < subImageCountWanted; ++j)
                    {
                        texture.SubImageArray[j] = image.SubImageArray[i * subImageCount + j];
                        dataSize += texture.SubImageArray[j].SlicePitch;
                    }

                    texture.Data = texture.SubImageArray[0].Data;
                    texture.DataSize = dataSize;

                    request.Textures.Add(texture);
                }
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:73,代码来源:ArrayTexLib.cs

示例2: Insert

        /// <summary>
        /// Inserts the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="tex">The tex.</param>
        /// <returns></returns>
        private bool Insert(Node node, TexImage tex)
        {
            if (node.IsEmpty() && node.IsLeaf())
            {
                if (node.Width < tex.Width || node.Height < tex.Height)
                {
                    return false;
                }
                else if (node.Width == tex.Width && node.Height == tex.Height)
                {
                    node.Texture = (TexImage)tex.Clone(false);
                    return true;
                }

                if (node.Width - tex.Width >= node.Height - tex.Height)
                {
                    node.Left = new Node(node.X, node.Y, tex.Width, node.Height);
                    node.Right = new Node(node.X + tex.Width, node.Y, node.Width - tex.Width, node.Height);
                    return Insert(node.Left, tex);
                }
                else
                {
                    node.Left = new Node(node.X, node.Y, node.Width, tex.Height);
                    node.Right = new Node(node.X, node.Y + tex.Height, node.Width, node.Height - tex.Height);
                    return Insert(node.Left, tex);
                }
            }
            else if (!node.IsLeaf())
            {
                return Insert(node.Left, tex) || Insert(node.Right, tex);
            }
            else
            {
                return false;
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:42,代码来源:AtlasTexLibrary.cs


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