0
PictureBox
にビットマップを表示するときに、にVisual Studio C++という問題があります。単純化するために、私はちょうどPictureBox
で表示されるグラデーションを作成したいと思います。しかし、私はこれらの周期的な黒い縞を画像を通して得る。 imageWidth
は640で、imageHeight
は480です。tempImage
割り当てでは、単純なグラデーションを作成し、すべてのピクセルをの白(255)に割り当てることを試みました。Visual Studioでビットマップオブジェクトを作成する際の問題2015
ご協力いただければ幸いです。
tempImage = new unsigned char *[imageHeight];
for (int count = 0; count < imageHeight; ++count) {
tempImage[count] = new unsigned char[imageWidth * 3];
}
// populate image
int i, j;
for (i = 0; i < imageHeight; ++i) {
for (j = 0; j < imageWidth; ++j) {
tempImage[i][j * 3] = 255; // i * 255/imageHeight;
tempImage[i][j * 3 + 1] = 255; // i * 255/imageHeight;
tempImage[i][j * 3 + 2] = 255; // i * 255/imageHeight;
}
}
Bitmap ^mybm = gcnew Bitmap(imageWidth, imageHeight, imageWidth * sizeof(unsigned char) * 3, Imaging::PixelFormat::Format24bppRgb,(IntPtr) tempImage);
this->SImage->Image = mybm;
this->SImage->Show();
これはうまくいきました(私は割り当て行を 'tempImage [i * 3 * imageWidth + j * 3] = 255;' –
に変更しなければなりませんでした)また、 'Bitmap'コンストラクタの3番目のパラメータあなたは現在それをやっているとは思わない。 –
ありがとう。私のビットマップは常に640x480または1024x768のいずれかになります。 –