I'm having issues displaying a Bitmap to a PictureBox in Visual Studio C++. To simplify things, I just want to create a gradient that is displayed in a PictureBox. However, I get these periodic black streaks through the image. I get these even if I set all the byte values to 255. imageWidth is 640 and imageHeight is 480. In the tempImage assignments, I have tried both creating a simple gradient and assigning all pixels to white (255).
Any help would be greatly appreciated.
    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();
      
 
Aucun commentaire:
Enregistrer un commentaire