public TextureArray2D Run(TextureArray2D src, Size3 dstSize)
        {
            Debug.Assert(src.Size != dstSize);
            var genMipmaps = src.HasMipmaps;
            var numMipmaps = 1;

            if (genMipmaps)
            {
                numMipmaps = ImagesModel.ComputeMaxMipLevels(dstSize);
            }

            bool changeWidth  = dstSize.Width != src.Size.Width;
            bool changeHeight = dstSize.Height != src.Size.Height;

            if (changeWidth)
            {
                var curMips = numMipmaps;

                if (changeHeight) // only temporary texture with a single mipmap
                {
                    curMips = 1;
                }

                var tmp = new TextureArray2D(src.NumLayers, curMips, new Size3(dstSize.Width, src.Size.Height), src.Format, false);
                Apply(src, tmp, 1, 0);
                src = tmp;
            }

            if (changeHeight)
            {
                var tmp = new TextureArray2D(src.NumLayers, numMipmaps, dstSize, src.Format, false);

                Apply(src, tmp, 0, 1);
                if (changeWidth) // delete temporary texture created by width invocation
                {
                    src.Dispose();
                }
                src = tmp;
            }

            if (genMipmaps)
            {
                src.RegenerateMipmapLevels();
            }

            return(src);
        }