有没有办法在C#中模拟接口中的静态函数?
我想将它用于工厂,其中每个对象都继承自ICreateAble静态函数'Create',然后在工厂类中可以调用Factory.Create(Type t, string fromFile)哪个调用t.Create()
有没有办法在特定路径中获取png文件的尺寸?我不需要加载文件,我只需要在directx中加载纹理的宽度和高度.
(我不想使用任何第三方库)
我在另一个线程读取,我可以读取Texture.Lock /解锁单个像素,但我需要阅读它们之后的像素写回的质感,这是我到目前为止的代码
unsigned int readPixel(LPDIRECT3DTEXTURE9 pTexture, UINT x, UINT y)
{
D3DLOCKED_RECT rect;
ZeroMemory(&rect, sizeof(D3DLOCKED_RECT));
pTexture->LockRect(0, &rect, NULL, D3DLOCK_READONLY);
unsigned char *bits = (unsigned char *)rect.pBits;
unsigned int pixel = (unsigned int)&bits[rect.Pitch * y + 4 * x];
pTexture->UnlockRect(0);
return pixel;
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
- How to write the pixels back to the texture?
- How to get the ARGB values from this unsigned int?
Run Code Online (Sandbox Code Playgroud)
((BYTE)x >> 8/16/24)对我没用(函数的返回值是688)
函数ntohl为我提供了一个链接器错误:
error LNK2001: unresolved external symbol _ntohl@4
fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)
我已经包括在内
#include <winsock.h>
Run Code Online (Sandbox Code Playgroud)
有具体原因吗?(或者可以手动轻松完成此功能吗?)