For fun, I want to write my own image format. I'm going to have to draw pixels to a Window, but I haven't found any nice, simple, light librarys that can do this. I've thought about using OpenGL, but it's kind of messy and over-complicated to write code for and a lot of the time it doesn't seem to agree with me. All I need the graphics library to do is initialise a window for me, and let me feed it an X,Y and RGB so I can plot pixels.

Any suggestions?

CImg springs to mind. Here is a complete working program to draw a 500x400 image on screen, with one pixel set to green. It is C++, though; have you got your heart set on doing it completely in C?

#include "CImg.h"
#include <iostream>
using namespace cimg_library;

int main()
    // create image size 500x400x1,3 channels (RGB) default colour white
    CImg<unsigned char>  theImage(500,400,1,3,1);

    // Now change one pixel value
    theImage(10,10,1) = 255; // different colour on pixel 10, 10- green to max

    CImgDisplay main_disp(theImage); // display it
    std::cin.ignore(); //wait
Perfect answer, cheers!

Wow, that's abolutely perfect! Precisely what I was looking for. Yeah the fact that it's in C++ is absolutely fine, doesn't worry me in the slightest.

This question has already been answered. Start a new discussion instead.