在C#下不存在D3DXSaveSurfaceToFile()! [英] D3DXSaveSurfaceToFile() does not exist under C#!

查看:74
本文介绍了在C#下不存在D3DXSaveSurfaceToFile()!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的开始让我感到沮丧。有人请证明我错了。


这是DX 9 sdk中函数的链接。
http://msdn.microsoft .com / library / de ... facetofile.asp


以下dll'在我的程序中被引用。

Microsoft.DirectX .dll

Microsoft.DirectX.Direct3D.dll

Microsoft.DirectX.Direct3DX.dll


代码:


使用Microsoft.DirectX;

使用Microsoft.DirectX.Direct3D;

..

..

//这里试图调用D3DXSaveSurfaceToFile

//参数错误但不是问题

D3DXSaveSurfaceToFile();


我得到的错误:MainFrom中不存在该名称...... bla bla


换句话说,我无法找到该功能。在哪里?

请帮助。


如果有帮助,这里是我想要做的链接。链接在C ++中唯一的

问题。
http://www.codeproject.com/dialog/sc...doing%20it%20:


提前致谢。

解决方案

" Nick" < PA ***** @ optonline.net>在消息中写道

新闻:QA ***************** @ news4.srv.hcvlny.cv.net ..。

这真的开始让我感到沮丧。有人请证明我错了。

这是DX 9 sdk中的功能链接。
http://msdn.microsoft.com/library /de...facetofile.asp
我的程序中引用了dll'。
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll Microsoft.DirectX.Direct3DX.dll

代码:

使用Microsoft.DirectX;
使用Microsoft.DirectX.Direct3D;


//这里试图调用D3DXSaveSurfaceToFile
//参数错误但不是问题
D3DXSaveSurfaceToFile();

我得到的错误: MainFrom中不存在该名称...... bla bla

换句话说,我找不到这个功能。在哪里?
请帮助。

如果有帮助,这里是我想要做的链接。链接在C ++中唯一的问题。


http://www.codeproject.com/dialog/sc...doing%20it%20:


您必须使用interop来调用dll中的API方法。网上有大量的例子,我建议你检查google或codeproject。

想法是将dll中的条目(你需要的)映射到一个C#

等价的方法,并调用映射的方法。


HTH,

---

Tom Tempelaere


TT(Tom Tempelaere)写道:

" Nick" < PA ***** @ optonline.net>在消息中写道
新闻:QA ***************** @ news4.srv.hcvlny.cv.net ..

这真的开始让我感到沮丧。有人请证明我错了。

这是DX 9 sdk中函数的链接。



http:/ /msdn.microsoft.com/library/de...facetofile.asp

我的程序中引用了dll'。
Microsoft.DirectX .dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

代码:

使用Microsoft.DirectX;

//这里试图调用D3DXSaveSurfaceToFile
//参数错误但不是问题
D3DXSaveSurfaceToFile ();

我得到的错误:MainFrom中不存在该名称...... bla bla

换句话说,我找不到这个功能。在哪里?
请帮助。

如果有帮助,这里是我想要做的链接。链接在C ++中唯一的问题。



http://www.codeproject.com/dialog/sc...doing%20it%20:

您将不得不使用interop来调用dll中的API方法。网上有很多例子,我建议你查看谷歌或代码项目。
想法是将dll中的条目(你需要的)映射到C#
等效方法,并调用映射的方法。

HTH,
--- Tom Tempelaere




对不起,如果我遗漏了什么,但我怎么知道C#等价的

方法?我找到的方法的唯一文档是在C ++中。


以下是来自头文件d3dx9tex.h,它是dx 9 sdk的一部分。


// ------------------------------------------ ----------------------------------

// D3DXSaveSurfaceToFile:

// ----------------------

//将表面保存到图像文件。

//

//参数:

// pDestFile

//目标文件的文件名

// DestFormat

// D3DXIMAGE_FILEFORMAT指定保存时使用的文件格式。

// pSrcSurface

//源表面,包含要保存的图像

// pSrcPalette

// 256色的源调色板,或NULL

// pSrcRect

//源矩形,或整个图像的NULL

//

// ---------------- -------------------------------------------------- ----------


HRESULT W INAPI

D3DXSaveSurfaceToFileA(
LPCSTR pDestFile,

D3DXIMAGE_FILEFORMAT DestFormat,

LPDIRECT3DSURFACE9 pSrcSurface,

CONST PALETTEENTRY * pSrcPalette,

CONST RECT * pSrcRect);


HRESULT WINAPI

D3DXSaveSurfaceToFileW(

LPCWSTR pDestFile,

D3DXIMAGE_FILEFORMAT DestFormat,

LPDIRECT3DSURFACE9 pSrcSurface,

CONST PALETTEENTRY * pSrcPalette,

CONST RECT * pSrcRect);


#ifdef UNICODE

#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW

#else

#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA

#endif


------------------------ -------------------------------------------------- -----


如果你能帮助我使用这个功能,我真的很赞赏它。


这是我到目前为止。


[DllImport(" Direct3DX.dll",EntryPoint =" D3DXSaveSurf aceToFile")]

//我对最后两个参数一无所知所以我把它们排除了,它们

//可以为null,但我仍然需要一个C#等价物。

/ / ImageFileFormat我基本上猜到了,所以不知道那是不是正确

//相当于D3DXIMAGE_FILEFORMAT

//我很确定C#中的HRESULT是Int32

//和LPCSTR是String

static extern Int32 D3DXSaveSurfaceToFile(String

pDestFile,ImageFileFormat DestFormat,Surface pSrcSurface);


//然后将其用作

D3DXSaveSurfaceToFile(" 2.bmp",ImageFileFormat.Bmp,mySurface);


该程序不会崩溃或任何事情,但2.bmp不存在。 =(


另外,我尝试运行tdump Direct3DX.dll并且功能不是

列出。


感谢您的帮助。


" Nick"< pa ***** @ optonline.net>写在消息中

news:_f ******************* @ news4.srv.hcvlny.cv.net ...

TT(Tom Tempelaere)写道:

" Nick"< pa ***** @ optonline.net>在消息中写道
新闻:QA ************* **** @ news4.srv.hcvlny.cv.net ..

这真的开始让我生气了。有人请证明我错了。

http://msdn.microsoft.com/library/de...facetofile.asp

我的程序中引用了dll'。
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

代码:

使用Microsoft.DirectX;
使用Microsoft.DirectX.Direct3D;


//这里试图调用D3DXSaveSurfaceToFile
//参数错误但不是问题
D3DXSaveSurfaceToFile();

我得到的错误:MainFrom中不存在名称...... bla bla

换句话说,我找不到这个功能。在哪里?
请帮助。

如果有帮助,这里是我想要做的链接。链接在C ++中唯一的问题。



http://www.codeproject.com/dialog/sc...doing%20it%20:
您将不得不使用interop来调用dll中的API方法。网上有很多例子,我建议你查一下google或
codeproject。我们的想法是将dll中的条目(你需要的)映射到C#
等效方法,然后调用映射的方法。

HTH,
--- < Tom Tempelaere



如果我遗失了什么,我很抱歉,但我怎么知道C#等价的方法?我找到的方法的唯一文档是在C ++中。

以下是来自头文件d3dx9tex.h,它是dx 9的一部分



sdk。

// -------------------------------------- ------------------------------------

- // D3DXSaveSurfaceToFile:
// ----------------------
//将表面保存到图像文件中。
//
//参数:
// pDestFile
//目标文件的文件名
// DestFormat
// D3DXIMAGE_FILEFORMAT指定保存时使用的文件格式。
// pSrcSurface
//源表面,包含要保存的图像
// pSrcPalette
// 256色的源调色板,或NULL
// pSrcRect //源矩形,或整个图像的NULL
//

// ---------------------- -------------------------------------------------- -

-
HRESULT WINAPI
D3DXSaveSurfaceToFileA(
LPCSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY * pSrcPalette,
CONST RECT * pSrcRect);

HRESULT WINAPI
D3DXSaveSurfaceToFileW (
LPCWSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY * pSrcPalette,
CONST RECT * pSrcRect);

# ifdef UNICODE
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW
#else
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA
#endif

------------ -------------------------------------------------- ------------
-----
如果你能帮助我把这个功能付给
工作,我真的很感激。
这个就是我到目前为止。

[DllImport(" Direct3DX.dl l",EntryPoint =" D3DXSaveSurf aceToFile")]
//我对最后两个参数一无所知所以我把它们排除了,它们可以为null,但我仍然需要一个C#相当。
// ImageFileFormat我基本上猜到了,所以不知道这是否正确
//等同于D3DXIMAGE_FILEFORMAT
//我很确定C#中的HRESULT是Int32
//和LPCSTR是String
static extern Int32 D3DXSaveSurfaceToFile(String
pDestFile,ImageFileFormat DestFormat,Surface pSrcSurface);

//然后将其用作
D3DXSaveSurfaceToFile (2.bmp,ImageFileFormat.Bmp,mySurface);

程序没有崩溃或任何东西,但2.bmp不存在。 =(

此外,我尝试运行tdump Direct3DX.dll并且没有列出功能。

感谢您的帮助。




您必须从API中映射您使用的功能,其中包括

参数映射和返回值(也称为编组)。在API中使用

应该映射,这涉及内存布局和打包

规范。问题是你使用的dll不是为.NET编写的

或C#(如果我正确读取)但是对于C / C ++。那么如果你想使用dll,那么除了使用.NET中的互操作性功能之外别无选择。

网上的文章,例如google,或 http://www.codeproject .com
http://www.codeguru.com 有很多。


否则,试着找一个.NET组件这是一样的。我没有直接使用DirectX的

程序,所以我无法帮助你。


HTH,

---

Tom Tempelaere


This is really starting to piss me off. Someone please prove me wrong.

Here is a link to the function in DX 9 sdk.
http://msdn.microsoft.com/library/de...facetofile.asp

Following dll''s are referenced in my program.
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

The code:

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
..
..
//here trying to call D3DXSaveSurfaceToFile
//the parameters are wrong but thats not the problem
D3DXSaveSurfaceToFile();

The eror I get: "The name does not exist in MainFrom..." bla bla

In other words, I cannot locate the function. Where is it?
Please help.

If it helps, here is the link to what I am trying to do. The only
problem the link is in C++.
http://www.codeproject.com/dialog/sc...doing%20it%20:

Thanks in advance.

解决方案

"Nick" <pa*****@optonline.net> wrote in message
news:QA*****************@news4.srv.hcvlny.cv.net.. .

This is really starting to piss me off. Someone please prove me wrong.

Here is a link to the function in DX 9 sdk.
http://msdn.microsoft.com/library/de...facetofile.asp
Following dll''s are referenced in my program.
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

The code:

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
.
.
//here trying to call D3DXSaveSurfaceToFile
//the parameters are wrong but thats not the problem
D3DXSaveSurfaceToFile();

The eror I get: "The name does not exist in MainFrom..." bla bla

In other words, I cannot locate the function. Where is it?
Please help.

If it helps, here is the link to what I am trying to do. The only
problem the link is in C++.


http://www.codeproject.com/dialog/sc...doing%20it%20:

You will have to use interop to call API methods in the dll. There are
plenty of examples on the net, I suggest you check google or codeproject.
The idea is to map the entries in the dll (the ones you need) to a C#
equivalent method, and call the mapped methods.

HTH,
---
Tom Tempelaere


TT (Tom Tempelaere) wrote:

"Nick" <pa*****@optonline.net> wrote in message
news:QA*****************@news4.srv.hcvlny.cv.net.. .

This is really starting to piss me off. Someone please prove me wrong.

Here is a link to the function in DX 9 sdk.



http://msdn.microsoft.com/library/de...facetofile.asp

Following dll''s are referenced in my program.
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

The code:

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
.
.
//here trying to call D3DXSaveSurfaceToFile
//the parameters are wrong but thats not the problem
D3DXSaveSurfaceToFile();

The eror I get: "The name does not exist in MainFrom..." bla bla

In other words, I cannot locate the function. Where is it?
Please help.

If it helps, here is the link to what I am trying to do. The only
problem the link is in C++.



http://www.codeproject.com/dialog/sc...doing%20it%20:

You will have to use interop to call API methods in the dll. There are
plenty of examples on the net, I suggest you check google or codeproject.
The idea is to map the entries in the dll (the ones you need) to a C#
equivalent method, and call the mapped methods.

HTH,
---
Tom Tempelaere



I''m sorry if I am missing something, but how do I know the C# equivalent
method? The only documentation of the method that I found is in C++.

The following is from the header file d3dx9tex.h, which is part of dx 9 sdk.

//----------------------------------------------------------------------------
// D3DXSaveSurfaceToFile:
// ----------------------
// Save a surface to a image file.
//
// Parameters:
// pDestFile
// File name of the destination file
// DestFormat
// D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
// pSrcSurface
// Source surface, containing the image to be saved
// pSrcPalette
// Source palette of 256 colors, or NULL
// pSrcRect
// Source rectangle, or NULL for the entire image
//
//----------------------------------------------------------------------------

HRESULT WINAPI
D3DXSaveSurfaceToFileA(
LPCSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect);

HRESULT WINAPI
D3DXSaveSurfaceToFileW(
LPCWSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect);

#ifdef UNICODE
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW
#else
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA
#endif

-------------------------------------------------------------------------------

I would really apreciate it if you could help me get this function to work.

This is what I have so far.

[DllImport("Direct3DX.dll",EntryPoint="D3DXSaveSurf aceToFile")]
//I have no clue about the last two arguments so I left them out, they
//can be null, but I still need a C# equivalent.
//ImageFileFormat I basically guessed, so dont know if thats the right
//equivalent to D3DXIMAGE_FILEFORMAT
//I''m pretty sure that HRESULT in C# is Int32
//and LPCSTR is String
static extern Int32 D3DXSaveSurfaceToFile(String
pDestFile,ImageFileFormat DestFormat,Surface pSrcSurface);

//and then use it as
D3DXSaveSurfaceToFile("2.bmp",ImageFileFormat.Bmp, mySurface);

The program doesn''t crash or anything, but 2.bmp is not there. =(

Also, I tried running "tdump Direct3DX.dll" and the funtions were not
listed.

Thank you for the help.


"Nick" <pa*****@optonline.net> wrote in message
news:_f*******************@news4.srv.hcvlny.cv.net ...

TT (Tom Tempelaere) wrote:

"Nick" <pa*****@optonline.net> wrote in message
news:QA*****************@news4.srv.hcvlny.cv.net.. .

This is really starting to piss me off. Someone please prove me wrong.

Here is a link to the function in DX 9 sdk.

http://msdn.microsoft.com/library/de...facetofile.asp

Following dll''s are referenced in my program.
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll

The code:

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
.
.
//here trying to call D3DXSaveSurfaceToFile
//the parameters are wrong but thats not the problem
D3DXSaveSurfaceToFile();

The eror I get: "The name does not exist in MainFrom..." bla bla

In other words, I cannot locate the function. Where is it?
Please help.

If it helps, here is the link to what I am trying to do. The only
problem the link is in C++.



http://www.codeproject.com/dialog/sc...doing%20it%20:
You will have to use interop to call API methods in the dll. There are
plenty of examples on the net, I suggest you check google or codeproject. The idea is to map the entries in the dll (the ones you need) to a C#
equivalent method, and call the mapped methods.

HTH,
---
Tom Tempelaere



I''m sorry if I am missing something, but how do I know the C# equivalent
method? The only documentation of the method that I found is in C++.

The following is from the header file d3dx9tex.h, which is part of dx 9


sdk.
//--------------------------------------------------------------------------
-- // D3DXSaveSurfaceToFile:
// ----------------------
// Save a surface to a image file.
//
// Parameters:
// pDestFile
// File name of the destination file
// DestFormat
// D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
// pSrcSurface
// Source surface, containing the image to be saved
// pSrcPalette
// Source palette of 256 colors, or NULL
// pSrcRect
// Source rectangle, or NULL for the entire image
//
//--------------------------------------------------------------------------
--
HRESULT WINAPI
D3DXSaveSurfaceToFileA(
LPCSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect);

HRESULT WINAPI
D3DXSaveSurfaceToFileW(
LPCWSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE9 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect);

#ifdef UNICODE
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW
#else
#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA
#endif

-------------------------------------------------------------------------- -----
I would really apreciate it if you could help me get this function to work.
This is what I have so far.

[DllImport("Direct3DX.dll",EntryPoint="D3DXSaveSurf aceToFile")]
//I have no clue about the last two arguments so I left them out, they
//can be null, but I still need a C# equivalent.
//ImageFileFormat I basically guessed, so dont know if thats the right
//equivalent to D3DXIMAGE_FILEFORMAT
//I''m pretty sure that HRESULT in C# is Int32
//and LPCSTR is String
static extern Int32 D3DXSaveSurfaceToFile(String
pDestFile,ImageFileFormat DestFormat,Surface pSrcSurface);

//and then use it as
D3DXSaveSurfaceToFile("2.bmp",ImageFileFormat.Bmp, mySurface);

The program doesn''t crash or anything, but 2.bmp is not there. =(

Also, I tried running "tdump Direct3DX.dll" and the funtions were not
listed.

Thank you for the help.



You will have to map the functions you use from the API, which includes
mapping of parameters & return values (aka marshalling). Also structs used
in the API should be mapped, which involves memory-layout and packing
specifications. The problem is that the dll you use is not written for .NET
or C# (If I Read Correctly) but for C/C++. Then there is no choice but to
use interoperability features in .NET if you want to use the dll. Check for
articles on the net, e.g. google, or http://www.codeproject.com or
http://www.codeguru.com. There are plenty.

Otherwise, try to find a .NET assembly which does the same. I don''t make
programs that use DirectX directly, so I can''t help you with that.

HTH,
---
Tom Tempelaere


这篇关于在C#下不存在D3DXSaveSurfaceToFile()!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆