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]);
}
これは、C の Encoder_GetCurrentCodecPixFmts 関数です。
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この新しいクラスのコンストラクターは空である必要がありますが、リストのインスタンスをリストのNEWにするためにどこかが必要でした。
C++ では、pix_fmts char 配列から codec->Supported に転送するか、pix_fmts から :List にコピーする必要があります
だから私は上記のようにしました:
codec->SupportedPixelFormats->Add(pix_fmts[i]);
しかし、これがコピーの意味かどうかはわかりません。
それは私がしたことですか?