本文介绍了DirectX9任意大小的纹理(非2 ^ n)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是DirectX的新手,必须在现有的C ++ DX9应用程序上工作。该应用程序对摄像机图像进行跟踪,并显示一些DirectDraw(即2d)内容。相机的纵横比为4:3(总是),屏幕未定义。

I'm relatively new to DirectX and have to work on an existing C++ DX9 application. The app does tracking on a camera images and displays some DirectDraw (ie. 2d) content. The camera has an aspect ratio of 4:3 (always) and the screen is undefined.

我想加载纹理并使用此纹理作为掩码,并且仅在纹理的掩蔽区域内进行内容的显示。因此,我想加载一个尺寸与相机图像完全相同的纹理。

I want to load a texture and use this texture as a mask, so tracking and displaying of the content only are done within the masked area of the texture. Therefore I'd like to load a texture that has exactly the same size as the camera images.

我已经完成了所有步骤来加载纹理,但是当我调用 GetDesc() code> D3DSURFACE_DESC struct是下一个更大的2的幂。我不在乎用于纹理的实际内存是针对显卡优化的,但我没有找到任何方法来获取原始图像文件在硬盘上的尺寸。

I've done all steps to load the texture, but when I call GetDesc() the fields Width and Height of the D3DSURFACE_DESC struct are of the next bigger power-of-2 size. I do not care that the actual memory used for the texture is optimized for the graphics card but I did not find any way to get the dimensions of the original image file on the harddisk.

我做(并没有成功,但没有成功)搜索一个可能性加载到计算机的RAM只有图形卡(不需要图形卡),而无需添加一个新的依赖关系的代码。否则,我将不得不使用OpenCV(这可能反正是一个好主意,当涉及到跟踪),但在这一刻我仍然尽量避免包括OpenCV。

I do (and did, but with no success) search a possibility to load the image into the computers RAM only (graphicscard is not required) without adding a new dependency to the code. Otherwise I'd have to use OpenCV (which might anyway be a good idea when it comes to tracking), but at the moment I still try to avoid including OpenCV.

感谢您的提示,
Norbert

thanks for your hints,Norbert

推荐答案

(参数3和4为

D3DX_DEFAULT_NONPOW2.

之后,您可以使用

D3DSURFACE_DESC Desc;
m_Sprite->GetLevelDesc(0, &Desc);

获取高度&

这篇关于DirectX9任意大小的纹理(非2 ^ n)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:02