C# 将多个小纹理组合为大纹理

C# 将多个小纹理组合为大纹理,c#,directx,textures,managed-directx,C#,Directx,Textures,Managed Directx,对此很抱歉,可能这是一个非常基本的问题,我有多个不同大小和坐标的小纹理,我想在此应用一些过渡。所以我需要将所有这些纹理组合在一个大纹理中,以形成一个屏幕大小的纹理 我想说,如果您不需要实时执行此操作(即源纹理不改变),那么只需在您最喜欢的图形编辑器(例如mspaint!)中执行即可 如果您确实想在游戏中执行此操作,请查看以下问题:您要查找的内容称为 在实时计算机图形学中,纹理图集是一个大图像,或“图集”,其中包含许多较小的子图像,每个子图像都是3D对象某个部分的纹理 谷歌搜索将为您提供摘要和生

对此很抱歉,可能这是一个非常基本的问题,我有多个不同大小和坐标的小纹理,我想在此应用一些过渡。所以我需要将所有这些纹理组合在一个大纹理中,以形成一个屏幕大小的纹理

我想说,如果您不需要实时执行此操作(即源纹理不改变),那么只需在您最喜欢的图形编辑器(例如mspaint!)中执行即可



如果您确实想在游戏中执行此操作,请查看以下问题:

您要查找的内容称为

在实时计算机图形学中,纹理图集是一个大图像,或“图集”,其中包含许多较小的子图像,每个子图像都是3D对象某个部分的纹理


谷歌搜索将为您提供摘要和生成摘要的工具。

为您的任务修改以下内容:

    /// <summary>
    /// Line up the textures in list horizontally. Warning: All textures MUST BE one height and in strong order
    /// </summary>
    /// <param name="device">D3D device</param>
    /// <param name="textures">List of textures</param>
    /// <returns>Combined texture</returns>
    public static Texture LineUpTexturesHorizontally ( Device device, List < Texture > textures )
    {
        int dstWidth = textures.Select ( texture => texture.GetSurfaceLevel ( 0 ) ).Select ( surface => surface.Description.Width ).Sum ( );
        int dstHeight = textures [ 0 ].GetSurfaceLevel ( 0 ).Description.Height;
        Texture dstTexture = CreateTexture ( device, dstWidth, dstHeight, Color.Orange, TexMipLevels, true );
        Surface dstSurface = dstTexture.GetSurfaceLevel ( 0 );
        Point insPoint = new Point ( 0, 0 );
        for ( int i = 0; i < textures.Count; i++ )
        {
            PaletteEntry [ ] pal; // = new PaletteEntry[ 256 ];
            Texture srcTexture = textures [ i ];
            Surface srcSurface = srcTexture.GetSurfaceLevel ( 0 );
            int srcWidth = srcSurface.Description.Width;
            int srcHeight = srcSurface.Description.Height;
            Rectangle srcRectangle = new Rectangle ( 0, 0, srcWidth, srcHeight );
            Rectangle dstRectangle = new Rectangle ( insPoint, new Size ( srcWidth, srcHeight ) );
            SurfaceLoader.FromSurface ( dstSurface, out pal, dstRectangle, srcSurface, out pal, srcRectangle, Filter.None, 0 );
            insPoint.X += srcWidth;
        }
        return dstTexture;
    }
//
///水平排列列表中的纹理。警告:所有纹理必须为同一高度且顺序严格
/// 
///D3D装置
///纹理列表
///组合纹理
公共静态纹理行横向纹理(设备设备,列表<纹理>纹理)
{
int dstWidth=textures.Select(texture=>texture.GetSurfaceLevel(0)).Select(surface=>surface.Description.Width.Sum();
int dstwheight=纹理[0]。GetSurfaceLevel(0)。Description.Height;
纹理dstTexture=CreateTexture(设备、dstWidth、dstHeight、Color.Orange、TexMipLevels、true);
Surface dstSurface=dstTexture.GetSurfaceLevel(0);
点insPoint=新点(0,0);
对于(int i=0;i
对于地形上的纹理,您是否也建议这样做?我指的是从高度贴图创建的网格。如果生成的纹理大小保持可控,那么在游戏开始之前可以做的任何事情都会更好。对于任意纹理,可以使用“精灵表”。这个工具做得很好,我有关于如何使用它的文档。嗨,欢迎使用StackOverflow。请考虑回答者是否容易回答,必要时编辑答案。谢谢