0
我在CLI这段代码如何复制到一个列表?
List<Codec^> ^GetCodecs()
{
List<Codec^> ^l = gcnew List<Codec^>;
bool KeepLooping = Encoder_MoveToFirstCodec();
while (KeepLooping)
{
Codec ^codec = gcnew Codec(); // here... and that call encoder_init many times... which call register codec many times... which is a mass...
codec->Name = gcnew String(Encoder_GetCurrentCodecName());
codec->Type = Encoder_GetCurrentCodecType();
char pix_fmts[200]; // array of 200 is probably enough
int actual_pix_fmts_sz = Encoder_GetCurrentCodecPixFmts(pix_fmts , 200);
for (int i = 0 ; i < actual_pix_fmts_sz ; i++)
{
//copy from pix_fmts to the :List
codec->SupportedPixelFormats->Add(pix_fmts[i]);
}
这是Encoder_GetCurrentCodecPixFmts功能在C:
int Encoder_GetCurrentCodecPixFmts(char *outbuf , int buf_sz)
{
int i=0;
while ((i<buf_sz) && (codec->pix_fmts[i]!=-1))
{
outbuf[i] = codec->pix_fmts[i];
i++;
}
return i;
}
这是一类新我所做的:
#pragma once
using namespace System;
using namespace System::Collections::Generic;
public ref class Codec
{
public:
String^ Name;
int ID; // this is the index
int Type; // this is the type
List<int> ^SupportedPixelFormats;
Codec(void)
{
SupportedPixelFormats = gcnew List<int>;
// do nothing in the constructor;
}
};
其中包含也是: SupportedPixelFormats 在这个新类的构造函数应该是空的,但我需要的地方,以便为列表中进行NE实例W为列表。
现在在C++我需要从pix_fmts字符数组转移到codec->支持 或者从pix_fmts复制到:列表
,所以我做如上:
codec->SupportedPixelFormats->Add(pix_fmts[i]);
但我我不确定这是否意味着复制。
,对不对我做了什么?
@ H2CO3你知道当你与水混合酸会发生什么:d – Shark 2013-05-08 20:24:04