I suggest looking into CImg. It is
- open source, CeCILL-C license (like GNU GPL)
- easy to use, because you just need to include a single header. No complex setup.
Bad news:
- AFAIK, you need to publish the source code of your software if someone asks you for it. Make sure you understand the impact of the license.
Here's code that creates an image of specific size in memory and draws some pixels:
#include "CImg.h"
using namespace cimg_library;
int main()
{
CImg<unsigned char> imgDrawPixel(100,200,1,3, false);
const unsigned char color[] = { 255,0,255 };
for (int i = 0; i < 50; i++)
{
imgDrawPixel.draw_point(i + 20, i + 20, color);
}
CImgDisplay main_disp(imgDrawPixel, "This is an image");
while (!main_disp.is_closed()) {
main_disp.wait();
}
return 0;
}
Result:

(The grey area is not part of the image. It's there because I can't make the window smaller.)