これは前に出てきたかもしれませんが、次のコードは、私が変更している MSDN の例から取られています。ビットマップに関するデータを含むバッファーの内容を反復処理して、色を出力する方法を知りたいです。各ピクセルは 4 バイトのデータであるため、RGB 値がこれらのバイトのうちの 3 つを占め、おそらく A が 4 番目であると想定しています。
その反復中にポイントされた値を、使用できるローカル変数に格納する、必要なポインター演算 (理想的にはループ内) の正しい C++ 構文は何ですか? コンソールに出力します。
どうもありがとう
PS。これは安全ですか?または、IMFMediaBuffer の内容をより安全に読み取る方法はありますか? 代替案が見つかりませんでした。
コードは次のとおりです。
hr = pSample->ConvertToContiguousBuffer(&pBuffer); // this is the BitmapData
// Converts a sample with multiple buffers into a sample with a single IMFMediaBuffer which we Lock in memory next...
// IMFMediaBuffer represents a block of memory that contains media data
hr = pBuffer->Lock(&pBitmapData, NULL, &cbBitmapData); // pBuffer is IMFMediaBuffer
/* Lock method gives the caller access to the memory in the buffer, for reading or writing:
pBitmapData - receives a pointer to start of buffer
NULL - receives the maximum amount of data that can be written to the buffer. This parameter can be NULL.
cbBitmapData - receives the length of the valid data in the buffer, in bytes. This parameter can be NULL.
*/