相关疑难解决方法(0)

将字节数组从C ++非托管dll传递给C#unity

我试图将字节数组从非托管C ++ dll返回给C#unity。非常感谢您抽出宝贵的时间来帮助> <我对DLL真的很陌生,因此我非常困惑两种语言甚至应该一起工作的方式。

CPP

问题出在这里,我已经完成了计算,但是我在努力寻找一种将其以数组格式返回给c#的方法。

当前,字节数组保存颜色代码,例如RGBA(223,124,23,255,212,143,234,255)并重复

#include "WebcamDLL.h"
#include <vector>

extern "C" {
int adjustBrightnesss(unsigned char* bytes, int sizeOfArray)
{
    std::vector<int> myvector;
    int alphaP = 0;
    for (int i = 0; i < sizeOfArray; i++) {
        switch (alphaP) {
        case 0:
        case 1:
        case 2:
            myvector[i] = bytes[i] / 2;
            alphaP++;
            break;
        case 3:
            alphaP = 0;
            break;
        }
    }
    return bytes;
}
}
Run Code Online (Sandbox Code Playgroud)

头文件

#ifdef TESTFUNCDLL_EXPORT
#define TESTFUNCDLL_API __declspec(dllexport) 
#else
#define TESTFUNCDLL_API __declspec(dllimport) 
#endif

extern "C" {
    TESTFUNCDLL_API …
Run Code Online (Sandbox Code Playgroud)

c# c++ dll unity-game-engine

2
推荐指数
1
解决办法
3499
查看次数

标签 统计

c# ×1

c++ ×1

dll ×1

unity-game-engine ×1