在 DirectX 中仅加载纹理的一部分?
如果我有一个纹理文件,如何使用定义的矩形(上、左、下、右)仅加载它的一部分?
从技术上讲,是否可以只读取我想要加载的部分,而保持纹理的其余部分不变?
If I have a texture file how would I be able to load up only a part of it using a defined rect (top, left, bottom, right)?
Is it technically possibly to only read in the parts I want to load while leaving the rest of the texture untouched?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您到底想实现什么目标。仅将文件的一小部分加载到包含所有文件的单个纹理中非常简单。不过,您可能需要编写自己的图像解析器。
如果您想将部分图像加载到与原始图像大小相同的纹理中(即仅更新您所在的区域),那么这也相对简单。您可以使用要更新的区域的矩形来锁定Rcts。不过,您仍然需要编写自己的图像解析器。
就我个人而言,在这种情况下,我更喜欢使用自己的纹理格式,该格式已经是我想要的格式......
What exactly are you trying to achieve. Its pretty simple to load up only a small part of a file into a single texture that encompasses it all. You'll probably need to write your own image parser, though.
If you want to load a partial image into a texture thats the same size as the original image (ie only update the area you are after) then this is relaitvely simple as well. You can LockRcts with a rect that is the area you want you update. You'll still need to write your own image parser though.
Personally in situations like this I prefer to use my own texture format that is already in the format I'm after ...
查看 D3DXCreateTextureFromFileEx:http://msdn。 microsoft.com/en-us/library/bb172802%28v=VS.85%29.aspx
否则,将您需要的数据部分加载到内存中,创建一个空纹理并锁定它并复制数据。
Look at D3DXCreateTextureFromFileEx: http://msdn.microsoft.com/en-us/library/bb172802%28v=VS.85%29.aspx
Otherwise, load the portion of the data you require yourself into memory, create an empty texture and lock it and copy the data.