// Create an empty 3 channel (RGB) image
IplImage* img = cvCreateImage(cvSize(640,480), IPL_DEPTH_8U, 3);
// Iterate over all of the rows of the image
for(int y = 0; y < 480; ++y)
{
// Iterate over all of the columns of each row
for(int x = 0; x < 640; ++x)
{
// Set each pixel to solid red
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 0] = 0; // B
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 1] = 0; // G
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 2] = 255; // R
}
}
// Save the image data as a bitmap
cvSaveImage("ImAfraidICantLetYouDoThatDave.bmp", img);
// Clean up our memory
cvReleaseImage(&img);
IplImage* img = cvCreateImage(cvSize(640,480), IPL_DEPTH_8U, 3);
// Iterate over all of the rows of the image
for(int y = 0; y < 480; ++y)
{
// Iterate over all of the columns of each row
for(int x = 0; x < 640; ++x)
{
// Set each pixel to solid red
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 0] = 0; // B
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 1] = 0; // G
((uchar *)(img->imageData + y*img->widthStep))[x*img->nChannels + 2] = 255; // R
}
}
// Save the image data as a bitmap
cvSaveImage("ImAfraidICantLetYouDoThatDave.bmp", img);
// Clean up our memory
cvReleaseImage(&img);