iTunes University/Harvard CS50 コースで C を独学しようとしています。その中には、ビットマップ画像ファイルのサイズを変更するプログラムが書かれています。これを行うために、配列 (バッファー) を定義し、プログラムが機能するために必要なコードを作成しました。実際に機能します。しかし、私はそれを理解することができなかったので、私は答えをだましてグーグルにしなければなりませんでした.私は解決策の特定の構文を理解していないので、誰かが助けてくれることを望んでいます.
コードのブロックは次のようになります。特定の混乱点をコメントに入れました。
// allocate array to hold scanline pixels - this is the array I define
RGBTRIPLE *buffer = malloc(bi.biWidth * sizeof(RGBTRIPLE));
// declare variable to track position in buffer array
int count;
// iterate over infile's scanlines
for (int i = 0, height = abs(oldHeight); i < height; i++)
{
// initialize count var to 0
count = 0;
// iterate over pixels in scanline
for (int j = 0; j < oldWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// place pixel in buffer array n times
for (int k = 0; k < n; k++)
{
// below is the confusion. Some sudo code would be great!
*(buffer+(count)) = triple;
count++;
}
}