Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 转换c++;数组和指向C的指针#_C#_C++_Arrays_.net_Pointers - Fatal编程技术网

C# 转换c++;数组和指向C的指针#

C# 转换c++;数组和指向C的指针#,c#,c++,arrays,.net,pointers,C#,C++,Arrays,.net,Pointers,我想知道如何将下面截取的(c++)转换成c。问题是C++代码使用指针符号,而不确定C中的等价物是什么。 尝试将C++代码转换成C语言,但不完全成功。 void DataExtractor::runM1(unsigned char* slice, unsigned short* frame, int nALines, int nHeight) { if (!slice) { return; }

我想知道如何将下面截取的(c++)转换成c。问题是C++代码使用指针符号,而不确定C中的等价物是什么。

尝试将C++代码转换成C语言,但不完全成功。

void DataExtractor::runM1(unsigned char* slice, unsigned short* frame, int nALines, int nHeight)
{
         if (!slice)
         {
            return;
         }
    
        // Apply 
        unsigned char* p1 = slice;
        for (int k = nHeight - 1; k >= 0; k--)
        {
            int nRow = (B_FLIP ? k : (nHeight - 1 - k));
    
            // Reverse order
            unsigned short* p2 = frame + nALines * nRow;
    
            unsigned short* p2End = p2 + nALines;
            for (; p2 < p2End;)
            {
                unsigned short M1 = unsigned short((NEW_MAX - NEW_MIN + 1) / 256.0)* *p1++ + NEW_MIN;
                if (M1 < 256)
                {
                    M1 = 256;
                }
                *p2++ = M1;
            }
        }
 }
void DataExtractor::runM1(无符号字符*切片,无符号短*帧,整数行,整数行)
{
如果(!切片)
{
返回;
}
//申请
无符号字符*p1=切片;
对于(int k=n右-1;k>=0;k--)
{
int nRow=(B_FLIP?k:(nHeight-1-k));
//逆序
无符号短*p2=帧+行*nRow;
无符号短*p2End=p2+nALines;
对于(;p2
调用顺序如下所示:

================================

DataExtractor* fdsDataExtract = new DataExtractor();
unsigned short** inputVol = new unsigned short*[nFrames];
float** preTopQVol = new float*[nFrames];

inputVol[iFrame] = new unsigned short[nALines*nHeight];
preTopQVol[iFrame] = new float[nALines*nHeight];

// Read Image Frame
unsigned char* slice = scanImage[iFrame];

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

dataExtractor->uncompressImg(slice, inputVol[iFrame], nALines, nHeight);

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

DataExtractor* fdsDataExtract = new DataExtractor();
unsigned short** inputVol = new unsigned short*[nFrames];
float** preTopQVol = new float*[nFrames];

inputVol[iFrame] = new unsigned short[nALines*nHeight];
preTopQVol[iFrame] = new float[nALines*nHeight];

// Read Image Frame
unsigned char* slice = scanImage[iFrame];

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

dataExtractor->uncompressImg(slice, inputVol[iFrame], nALines, nHeight);

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


DataExtractor.cpp
=====================

#include "DataExtractor.h"

#define B_FLIP 0
#define NEW_MIN 0
#define NEW_MAX 65535

void DataExtractor::uncompressImg(unsigned char * slice, unsigned short * inputImg, int nWidth, int nHeight)
{
    runM1(slice, inputImg, nWidth, nHeight);
}



void DataExtractor::runM1(unsigned char* slice, unsigned short* frame, int nALines, int nHeight)
{
    if (!slice)
    {
        return;
}

// Apply 
unsigned char* p1 = slice;
for (int k = nHeight - 1; k >= 0; k--)
{
    int nRow = (B_FLIP ? k : (nHeight - 1 - k));

    // Reverse order
    unsigned short* p2 = frame + nALines * nRow;

    unsigned short* p2End = p2 + nALines;
    for (; p2 < p2End;)
    {
        unsigned short M1 = unsigned short((NEW_MAX - NEW_MIN + 1) / 256.0)* *p1++ + NEW_MIN;
        if (M1 < 256)
        {
            M1 = 256;
        }
        *p2++ = M1;
    }
}
DataExtractor*fdsDataExtract=newdataextractor();
无符号短**inputVol=新的无符号短*[n帧];
浮动**preTopQVol=新浮动*[n帧];
inputVol[iFrame]=新的无符号短[nALines*nHeight];
preTopQVol[iFrame]=新浮点[nALines*nHeight];
//读取图像帧
无符号字符*切片=扫描图像[iFrame];
//-----------------------------------
数据提取器->解压缩(切片、inputVol[iFrame]、nALines、nHeight);
//----------------------------------
DataExtractor*fdsDataExtract=新的DataExtractor();
无符号短**inputVol=新的无符号短*[n帧];
浮动**preTopQVol=新浮动*[n帧];
inputVol[iFrame]=新的无符号短[nALines*nHeight];
preTopQVol[iFrame]=新浮点[nALines*nHeight];
//读取图像帧
无符号字符*切片=扫描图像[iFrame];
//-----------------------------------
数据提取器->解压缩(切片、inputVol[iFrame]、nALines、nHeight);
//----------------------------------
DataExtractor.cpp
=====================
#包括“DataExtractor.h”
#定义B_翻转0
#定义新的\u MIN 0
#定义新的\u MAX 65535
void DataExtractor::解压(无符号字符*切片,无符号短*inputImg,int nWidth,int nHeight)
{
runM1(切片、输入、nWidth、nHeight);
}
void DataExtractor::runM1(无符号字符*切片,无符号短*帧,整数行,整数行)
{
如果(!切片)
{
返回;
}
//申请
无符号字符*p1=切片;
对于(int k=n右-1;k>=0;k--)
{
int nRow=(B_FLIP?k:(nHeight-1-k));
//逆序
无符号短*p2=帧+行*nRow;
无符号短*p2End=p2+nALines;
对于(;p2指针可以用在<代码> ItpTrt/Cux>类型中。我想你想在C++中有与C++一样的功能,对吗?如果是这样,不要费心“翻译”代码。请写下这些要求,然后用C语言来实现。在托管的、安全的C代码中,没有完全等价的。所以,基本上是“做C的方式”。-乍一看,如果不是“更高”的集合类型,您可能希望使用数组和相应的索引。